Loggerhead setting 'Cache-Control' header for static fields

John Arbash Meinel john at arbash-meinel.com
Fri Apr 30 20:47:39 BST 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkvbM9sACgkQJdeBCYSNAAO6CwCeMLn5I5gnUmyiPVywVsc3uIVs
HcUAmwV/5L8ECynKhco4CkHOREShD56/
=9uUs
-----END PGP SIGNATURE-----



More information about the bazaar mailing list