Loggerhead setting 'Cache-Control' header for static fields

Matt Nordhoff mnordhoff at mattnordhoff.com
Fri Apr 30 21:12:01 BST 2010


John Arbash Meinel wrote:
> In the process of poking around the loggerhead codebase, I found this flag:
> 
> === modified file 'loggerhead/apps/__init__.py'
> --- loggerhead/apps/__init__.py 2009-11-26 03:44:40 +0000
> +++ loggerhead/apps/__init__.py 2010-04-30 19:28:16 +0000
> @@ -9,7 +9,7 @@
>  static = os.path.join(
>      os.path.dirname(os.path.dirname(__file__)), 'static')
> 
> -static_app = urlparser.make_static(None, static)
> +static_app = urlparser.make_static(None, static, cache_max_age=3600)
> 
>  favicon_app = convert_file_errors(fileapp.FileApp(
>      os.path.join(static, 'images', 'favicon.ico')))
> 
> 
> Setting the cache_max_age to something adds a header to the response like:
> 
>   Expires: Fri, 30 Apr 2010 20:28:21 GMT
>   Cache-Control: public, max-age=3600
> 
> Is this necessary to tell stuff like Squid it is ok to cache? I know it
> does set "ETag", and sending "If-None-Match: <etag>" does give a 304 Not
> Modified result.
> 
> However, I guess I don't really know the squid defaults. It would seem
> generally useful for us, since stuff in 'static' rarely changes. I don't
> know how much overhead this would save us. In testing locally, I've seen
> quite a few cases where the main page is displayed, but then Firefox
> seems to take several more seconds 'spinning' while it loads stuff that
> seems to be under /static, etc.
> 
> John
> =:->

No matter what Squid thinks, Expires/Cache-Control headers are the right
way to go. It's just nobody has gotten around to it, especially since
it's trickier for the dynamic pages.

bb:approve from me, although I'd be happy with something even higher,
like 43200 or 86400 seconds.
-- 
Matt Nordhoff



More information about the bazaar mailing list