When I generate a page I send headers
HTTP/1.1 200 OK
Cache-Control: private
Content-Type: text/html; charset=utf-8
Last-Modified: Mon, 04 Apr 2011 20:08:33 GMT
Vary: Accept-Encoding
Date: Mon, 11 Apr 2011 01:36:21 GMT
Content-Length: 3019
then, when I try to get this page again all browsers send correct request and get 304 answer except Safari - it never sends if-modified-since. It always reloads whole page even it havnt been changed
Does this behavior of Safari known and what to do to make Safari work in right way?
Safari is only partly free software. Other than holding your breath until Apple releases the whole of Safari as free software, as a Safari user you could use a caching proxy and configure it to break the spec and ignore the Cache-Control headers Safari sends.
Squid has the refresh_pattern directive, and I'm sure other proxies have similar functionality.
You can then configure Safari to use the proxy, or you can do it transparently in the spirit of upside-down-ternet.
Bart Lateur wrote a post about this, with a paragraph stating about Safari:
In my testing, Safari is expecting either an "Expires" or "Cache-Control" header along with "Last-Modified".
Or,
NOTE: "max-age" was required for Safari to honor the "Last-Modified"
I ran into this with Safari 8.0. Despite providing the
Last-Modified
header to Safari it would not provide theIf-Modified-Since
header on subsequent requests. The fix in my case was to additionally set theExpires
header to the same html-date as theLast-Modified
header.Here's an example of what the successful exchange looks like:
Initial Request
Standard first request from Safari.
Initial Response
I specify both the
Expires
andLast-Modified
headers as the same valid html-date. I have not tried but I doubt Safari will honor anExpires
header set to-1
.Subsequent Request
At last Safari provides the needed
If-Modified-Since
header.Subsequent Response
I can satisfyingly return a 304.