Safari not sending “If-Modified-Since” and “If-None-Match” headers

别说谁变了你拦得住时间么 提交于 2019-12-01 03:01:15

If-Modified-Since

The notes of If-Modified-Since warn against using something different than the contents of the Last-Modified response header:

Note: If a client uses an arbitrary date in the If-Modified-Since header instead of a date taken from the Last-Modified header for the same request, the client should be aware of the fact that this date is interpreted in the server's understanding of time.

Your response doesn't contain a Last-Modified, but even if it did, nothing in the spec says that user agents MUST or SHOULD send If-Modified-Since, they just MAY.

If-None-Match

As to why Safari doesn't send an If-None-Match beats me; your ETag looks valid.

Enforcing Caching in general

Again in general nothing in the spec says you MUST cache, just that when you do, you MUST obey Cache-Control. So it's a bit of an asymmetric relation, you can enforce (transparent) caches to recheck with the origin server, but as an origin server, you can't enforce useragents to cache.

What can I do about it?

Safari is only partly free software. So nothing much, if adding a Last-Modified doesn't help.

I ended up solving this one by looking for what headers are sent by various big sites, and have ended up with

Last-Modified: {some date}
Cache-Control: max-age=0, must-revalidate
Expires: -1

This is working on Safari for me.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!