When I send a 304 response. How will the browser interpret other headers which I send together with the 304?
E.g.
header("HTTP/1.1 304 Not Modified");
header("Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT");
Will this make sure the browser will not send another conditional GET request (nor any request) until $offset time has "run out"?
Also, what about other headers?
Should I send headers like this together with the 304:
header('Content-Type: text/html');
Do I have to send:
header("Last-Modified:" . $modified);
header('Etag: ' . $etag);
To make sure the browser sends a conditional GET request the next time the $offset has "run out" or does it simply save the old Last Modified and Etag values?
Are there other things I should be aware about when sending a 304 response header?
This blog post helped me a lot in order to tame the "conditional get" beast.
An interesting excerpt (which partially contradicts Ben's answer) states that:
This is in complete accordance with the RFC 2616 sec 10.3.5.
Below a 200 request...
...And its optimal valid 304 counterpart.
Notice that the
Expires
header is at mostCurrent Date + One Year
as per RFC-2616 14.21.The
Content-Type
header only applies to responses which contain a body. A 304 response does not contain a body, so that header does not apply. Similarly, you don't want to sendLast-Modified
orETag
because a 304 response means that the document hasn't changed (and so neither have the values of those two headers).For an example, see this blog post by Anne van Kesteren examining WordPress'
http_modified
function. Note that it returns eitherLast-Modified
andETag
or a 304 response.