我正在尝试禁用Hunchentoot的页面缓存,以简化本地主机上的web开发。
据我所知,应该使用函数no-cache,但我不确定如何合并此函数。我目前有以下代码可以正确地评估,但是这与动态提供的内容相关,所以我无法检查no-cache函数是否正确。此外,我也不知道如何向处理程序添加处理程序函数。
(hunchentoot:define-easy-handler
(test-fn :uri "/test.html") (name)
(setf (hunchentoot:content-type*) "text/plain")
(hunchentoot:no-cache)
(format nil "Hey~@[ ~A~]!" name))我找不到一种向静态分派和处理程序添加无缓存的方法,比如following
(push (hunchentoot:create-static-file-dispatcher-and-handler
"/url.html" "/path/to/www_/actual-page.html")
hunchentoot:*dispatch-table*)上面的例子绕过了缓存,因为我相信它是动态地为页面提供服务。
下面是我的服务器配置。当前正在缓存静态页面。我想了解Hunchentoot机制,该机制不仅禁用所有资源的缓存,还禁用指定资源的缓存(为其他资源保留它)。
(defvar *ssg-web-server* (hunchentoot:start
(make-instance 'hunchentoot:easy-acceptor
:address "127.0.0.1"
:port 4242
:document-root #p"/path/to/www_/"
:persistent-connections-p t
:read-timeout 3.0
:write-timeout 3.0
:access-log-destination nil
:message-log-destination nil)))发布于 2021-04-26 19:53:11
create-static-file-dispatcher-and-handler接受回调:
回调在发送文件之前运行,可用于设置头部或检查授权;参数是文件名和(猜测的)内容类型。
我想你可以这样写:
(defun no-cache-static-callback (file content-type)
(declare (ignore file content-type))
(no-cache))您将按如下方式传递此函数,即使用NIL content-type和回调函数:
(create-static-file-dispatcher-and-handler
"/url.html"
"/path/to/www_/actual-page.html"
nil
#'no-cache-static-callback)https://stackoverflow.com/questions/67257539
复制相似问题