apache - Expires 指令 - 修改基础 VS Access 基础

标签 apache .htaccess browser-cache mod-expires

据我所知:

ExpiresByType text/html "access plus 30 days"

将在内容存储 30 天后向浏览器缓存请求新内容。

但是:

ExpiresByType text/html "modification plus 30 days"

浏览器缓存将在 LAST MODIFIED HEADER 的帮助下知道,在修改 30 天之前不会请求新内容。

所以我的问题是,为什么不一直使用修改基础,因为它似乎更有意义或者我缺少什么?

最佳答案

apache mod_expires docs说这个:

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/

相关文章:

php - Centos 7/Apache/PHP - mkdir() : Permission denied

apache - 让我们用 htaccess 加密

node.js - 重写规则,以便正确加载具有绝对路径的 css 和 js 文件

php - 删除 .htaccess 中的扩展名时无法访问子文件夹中的文件

node.js - Nginx 删除端口号 :8080 in the url

apache - HTTP ://localhost/phppgadmin/-> 403 Forbidden

regex - 重定向所有子目录但不重定向父目录

php - 强制浏览器重新读取ajax结果

internet-explorer - 浏览器使用什么启发式方法来缓存未明确设置为可缓存的资源?

php - session 清空后退按钮浏览器缓存