[hunchentoot-devel] ETag, Cache-Control, and/or Expires headers

I need to prevent an intermediate cache from caching a static audio file I'm providing via register-static-file. What's the easiest way to set these for every reply (changing it dynamically, in the case of ETag)? Thanks, Patrick

Sorry. I mean create-static-file-dispatcher-and-handler, not register-static-file. Thanks, Patrick On 6 Jul 2009, at 20:24, Patrick May wrote:
I need to prevent an intermediate cache from caching a static audio file I'm providing via register-static-file. What's the easiest way to set these for every reply (changing it dynamically, in the case of ETag)?
Thanks,
Patrick
_______________________________________________ tbnl-devel site list tbnl-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/tbnl-devel

Since I have the list all to myself tonight, here's the answer I came up with: (defun register-uncached-static-file (name &optional (path *web-path*) content-type) "Register a static file with Hunchentoot, setting the headers to prevent caching. Dispatcher and handler code lifted from hunchentoot:create-static-file-dispatcher-and-handler." (push (lambda (request) ; the dispatcher (when (equal (hunchentoot:script-name request) (concatenate 'string "/" name)) (lambda () ; the handler (hunchentoot:no-cache) (hunchentoot:handle-static-file (concatenate 'string path "/" name) content-type)))) hunchentoot:*dispatch-table*)) Comments solicited and appreciated. Regards, Patrick On 6 Jul 2009, at 20:43, Patrick May wrote:
Sorry. I mean create-static-file-dispatcher-and-handler, not register-static-file.
Thanks,
Patrick
On 6 Jul 2009, at 20:24, Patrick May wrote:
I need to prevent an intermediate cache from caching a static audio file I'm providing via register-static-file. What's the easiest way to set these for every reply (changing it dynamically, in the case of ETag)?
Thanks,
Patrick
_______________________________________________ tbnl-devel site list tbnl-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/tbnl-devel
_______________________________________________ tbnl-devel site list tbnl-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/tbnl-devel

On 6 Jul 2009, at 20:24, Patrick May wrote:
I need to prevent an intermediate cache from caching a static audio file I'm providing via register-static-file. What's the easiest way to set these for every reply (changing it dynamically, in the case of ETag)?
I got some feedback from the maintainer of the intermediate cache that might be of interest. The problem I was seeing was that the intermediate cache wasn't understanding the type of the audio file I was serving. Both wav and mp3 formats were affected. It turns out that Hunchentoot sends a Content-Type header with a 304 (not modified) response. Apache and other common servers don't. RFC2616 section 10.3.5 says: "If the conditional GET used a strong cache validator (see section 13.3.3), the response SHOULD NOT include other entity-headers. Otherwise (i.e., the conditional GET used a weak validator), the response MUST NOT include other entity-headers; this prevents inconsistencies between cached entity-bodies and updated headers." Does this mean Hunchentoot is non-compliant? Regards, Patrick

On Tue, Jul 7, 2009 at 8:32 PM, Patrick May<patrick.may@mac.com> wrote:
Does this mean Hunchentoot is non-compliant?
I haven't looked at this in detail, but from what you quoted it seems like the function HANDLE-STATIC-FILE (or rather HANDLE-IF-MODIFIED-SINCE) which a TBNL user provided in 2004 and which has since essentially been unchanged is indeed non-compliant or rather too simple-minded. I don't have the time to fix this right now, but as usual, patches against the dev version at bknr.net are welcome. http://weitz.de/patches.html Thanks for the report, Edi.
participants (2)
-
Edi Weitz
-
Patrick May