Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Max-age and 304 Not Modified Processing

Tags:

http

I've been looking at the standards - but was not entirely sure about the following:

If we have a variant (resource, image, page etc) that is served with a cache setting of max-age=259200 (3 days) and the server is also processing ETags and last modified dates - then what will happen when the max-age is reached - but the resource has not been modified?

What I'm hoping will happen is that after 3 days - the client will request the resource again - and if it has not changed will received a 304 Not Modified response. If the cache control response (during the 304 response) also still contains max-age=259200 - then I'm hoping the client will continue to use its local cached copy and not request again for another 3 days.

What I'm afraid will happen is that once the max-age is reached - the client will no longer cache the resource - making a fresh request each time the resource is loaded - followed by a 304 Not Modified response if the resource has not been modified. i.e. we're now getting http requests for every use as opposed to using the local cache for another 3 days.

Thoughts?

like image 553
Blue Waters Avatar asked Jul 27 '09 10:07

Blue Waters


People also ask

What is the meaning of 304 not modified?

The HTTP 304 Not Modified client redirection response code indicates that there is no need to retransmit the requested resources. It is an implicit redirection to a cached resource.

What is the difference between 200 and 304 status code?

200 (cache) means Firefox is simply using the locally cached version. This is the fastest because no request to the Web server is made. 304 means Firefox is sending a "If-Modified-Since" conditional request to the Web server.


1 Answers

It will cache for 3 more days. RFC 2616 10.3.5:

If a cache uses a received 304 response to update a cache entry, the cache MUST update the entry to reflect any new field values given in the response.

Details about age calculation.

like image 72
Kornel Avatar answered Sep 28 '22 07:09

Kornel