据我所知:
ExpiresByType text/html "access plus 30 days"
将在内容存储 30 天后向浏览器缓存请求新内容。
但是:
ExpiresByType text/html "modification plus 30 days"
浏览器缓存将在 LAST MODIFIED HEADER 的帮助下知道,在修改 30 天之前不会请求新内容。
所以我的问题是,为什么不一直使用修改基础,因为它似乎更有意义或者我缺少什么?
最佳答案
The difference in effect is subtle. If M is used, all current copies of the document in all caches will expire at the same time, which can be good for something like a weekly notice that's always found at the same URL. If A is used, the date of expiration is different for each client; this can be good for image files that don't change very often, particularly for a set of related documents that all refer to the same images (i.e., the images will be accessed repeatedly within a relatively short timespan).
其中,M 是修改加号,A 是访问加号。因此,看起来这取决于您希望缓存如何在所有浏览器上工作。您是否希望您的资源的缓存在所有浏览器上同时过期?或者您是否希望您的资源的缓存过期在所有浏览器中交错?特别是,它取决于此处缓存的资源类型。
例如,如果我有一个页面,/live_shows.html
,除了每周一次之外,永远不会更改,我只在本周初更新它以列出所有实时内容显示我将在我的酒吧中使用,然后我将要使用“修改加上 7 天”
。因为每 7 天就会更新一次,不多也不少。
如果我有一个显示在 /live_shows.html
页面上的图像目录,但它们很少被更改,因为它们就像图标、横幅和项目符号,我会全部使用它们时间。然后我希望将它们设置为“访问加 30 天”
,因为如果有任何更改,获取这些更改的更新并不是那么重要。
关于apache - Expires 指令 - 修改基础 VS Access 基础,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12626011/