Etag/Last Modified - the numpty question I've always wanted to know.
|
02-03-2011, 11:38 AM
(This post was last modified: 02-04-2011 08:33 AM by jesper_mortensen.)
Post: #14
|
|||
|
|||
RE: Etag/Last Modified - the numpty question I've always wanted to know.
(01-28-2011 03:12 PM)Thompson Wrote: I've always heard (askapache.com) that for static content (JS/CSS), it's best to set far futures headers by setting *both* cache-control and expires headers. And then unsetting *both* etags and last modified. Cache-Control is a "strong" caching header, in the sense that it's unconditional. When you instruct caches via the cache-control header, they are allowed to cache the content for the indicated time without checking back with you. Expires acts in the same way. Cache-Control is a HTTP 1.1 header, and as such requires a HTTP 1.1 compliant cache. Expires is a HTTP 1.0 header. Personally, I don't serve both HTTP 1.1 and 1.0 caching headers anymore, I exclusively use the HTTP 1.1 Cache-Control. ETags and Last-Modified are not "weak" caching headers, they are conditional download / content headers. ETag is a header used for conditional downloads, with a clear meaning and pretty consistent implementations. Last-Modified is, well, the timestamp for when the content was last modified. But since it is timestamp-based, and quite old, you can find some inconsistent behavior when Last-Modified is used as the sole criteria for conditional downloading. If you want to manage caching, and have something that is simple to reason about, then there are IMHO 2 good solutions:
I base my suggestion of not using 304's in part on the following quote: "Cache Updates: Caches are required to be updated by the headers in 304 responses,[...] In practice, updates were spotty; a lot of the time, the test suite couldn’t get the cache into a state where it could tell, but when it could, there were failures. As a result, it’s probably not a good idea to rely on 304 responses or HEAD requests to update headers; better to just send a 200 back with a whole new representation." Mark Nottingham has a really good write-up on HTTP mechanisms for controlling caches here: http://www.mnot.net/cache_docs/ |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)