我知道这个问题已经被问了很多次。但是,我对这个概念还不是很清楚。在阅读了许多博客和SO上的答案之后,我得到的是:
Expiry headers are used when you don’t even want client (and proxies/caches) to make a request to
the server. In ETAG, the client will check with the server for the update, but in expiry
headers, the client will know, when to expire the file and check for an update, till then it
(browsers and proxies/caches) won’t bother server for checking the update.
基本上,如果我们使用expires / max-age标题,它甚至不会检查更新文件的服务器。因此,我想在本地进行测试。
所以我创建了一个简单的HTML文件,包括2个JS文件和1个图像文件。 在IIS中,我将Expires标题设置为图像文件夹的2天。 因此,根据我的理解,获取图像文件后,对于下一次请求,它不应向服务器发送请求以检查图像文件是否已修改。
但是我得到的是每次刷新页面时都会向服务器发送请求,并且服务器返回“304未修改”状态。 但是根据我阅读的规格/博客,它不应该向服务器发送请求。
请有人解释一下。