为什么有人将(Apache mod_expires参数)ExpiresByType设置为"access plus 0 seconds"? [英] why would anyone set (Apache mod_expires parameter) ExpiresByType to "access plus 0 seconds"?

查看:57
本文介绍了为什么有人将(Apache mod_expires参数)ExpiresByType设置为"access plus 0 seconds"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在审查对此帖子的答案,我不明白为什么在这里将0秒用于最佳实践:

In reviewing the answer to this post, I don't understand why 0 seconds is used for best practice here:

ExpiresByType text/html "access plus 0 seconds"

认为,这意味着每当用户访问该网站时,始终会下载html页面,而不是从缓存中提取该页面.是吗?

I think this means that whenever a user visits the website, the html page is always downloaded instead of pulled from cache. Is that right?

这是人们通常为此变量设置的吗?如果可以,为什么?如果没有,将其设置为0秒会带来哪些好处?

Is this what people typically set for this variable? If so why? If not, which scenarios benefit from setting it to 0 seconds?

推荐答案

如果 text/html 仅表示静态HTML文件中的内容",那您将是对的,并且希望设置更长的缓存寿命.但是服务器端脚本通常也会 返回网页;也就是说,他们的回复的Content-Type通常也会是 text/html .而且,如果所有HTML都已缓存,则动态生成的内容可能似乎无法正确更新.

If text/html only meant "content from static HTML files", you'd be right, and you'd want to set a longer cache life. But server-side scripts typically also return a web page; that is, their responses' Content-Type will often be text/html as well. And if all HTML were cached, dynamically generated content might not appear to update properly.

如果您只想使非静态HTML过期,则可以执行类似的操作

If you wanted to expire only non-static HTML, you might be able to do something like

<FilesMatch "\.php$">
    ExpiresByType text/html "access plus 0 seconds"
</FilesMatch>

(以PHP为例)

这篇关于为什么有人将(Apache mod_expires参数)ExpiresByType设置为"access plus 0 seconds"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆