Imagine a resource with a max-age
of 60 seconds:
- After 1 minute, the browser sends a conditional header
If-None-Match
- This checks if the etag of the resource has changed.
- If the etag has not changed, the server will return a
304 Not Modified
response.
Will this response automatically add a new 60 seconds to the max-age
? Or is this a case server needs to explicitly handle.
In section 4.2 of the HTTP caching specification it says the following:
The
max-age
directive tells the HTTP cache of the client that the response is good for 60 seconds. So once the server sends a 304 response, that cached response will be good for another 60 seconds.There's nothing to handle for the server here. It's up to the client's caching implementation to freshen the responses upon receiving a 304 response.