need cache headers on all static resources #620
Comments
I've done some research. Here's my conclusions. We have three types of URLs that should be treated differently:
Now for cache busting! we should always allow the client to specify a SHA somewhere in the request path, that will map to the original file. When this is done, we have perma-urls and we can put the max-age at a month or more. So it is up to the client to permute file paths with a version number wherever it can to improve the cacheability of resources. Ideally we'd have one 304 and a bunch of cache hits requiring no additional network traffic on each page load from a browser with a populated cache. |
… accept-locale, and *only* with an ETag but not last-modified (the two don't mix well, see rfc2616. issue #620
Disclaimer: I'm jumping in just looking at the proposed headers, but I'm not 100% sure what content you're serving and to what purposes, so this may be slightly off. |
@Seldaek thanks a ton for jumping in. love the with uniquely versioned file names approach, that's the way we want to go. Hadn't thought about the expires header in the past for old proxies, I'll add that. w.r.t ETags - we generate them and we do so by combining mtime, locale, and file size, so they should be consistent across our production servers. |
If you do uniquely versioned assets, for static files I would not use etags but rather far-future expires/max-age. For pages this is not practical since you can't really change the links all the time, so using ETag to save a bit on bandwidth might be good. |
@fetep can you confirm our deploy scripts will respect/ensure a consistent mtime across servers? |
Confirmed: http://irclog.gr/#show/irc.mozilla.org/identity/48316 --lloyd On Jan 29, 2012, at 7:20 PM, Mark Mayoreply@reply.github.com wrote:
|
Re-organized CSS and script tags in dialog_layout.ejs to give a feel for how this could work. |
Issue#226 raises the issue of cache busting image urls in CSS. The solution for this bug should be compatible with the connect compiler, so a Less based solution or some other solution can build on this bug. |
First pull request to fix this issue: |
Remaining work:
@shane-tomlinson - thoughts on how we get to #2? |
Filed Issue 1141. |
@shane-tomlinson If you want, I'll grab the images part of this bug. lloyd has proposed https://gist.github.com/1849619 and/or Spriting our images. I'll cook up a PR with LESS and we can pick a path. I'm to lazy to sprite and we can always do it later in it's own issue. |
Proposed fix |
Go team! |
Verified older changes in code for Stage. |
We need to figure out GH-226, and once done, we need to ensure cache headers are on all static resources. We should also add an in-tree unit test to verify we don't regress here.
/cc @vmunix @shane-tomlinson
The text was updated successfully, but these errors were encountered: