允许和控制缓存的最佳方式
Y慢
我正在使用雅虎的 YSlow 测试我的一些网站,并注意到以下评论:指定以下资源至少在未来一周到期
我的 .htacces 文件包含以下代码:
ExpiresActive On
ExpiresDefault "access plus 1 day"
这是最好的方法吗?为什么YSlow建议您设置缓存至少一周?
YSlow
I was testing some of my websites using Yahoo's YSlow and noticed the following comment:
Specify an expiration at least one week in the future for the following resources
My .htacces file contains the following code:
ExpiresActive On
ExpiresDefault "access plus 1 day"
Is this the best way to do it? And Why does YSlow advice you to set the cache for at least one week?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因为他们认为一天还不够长(这不是一个坏主意):如果您有一些用户每周只访问您的网站几次,则缓存 1 天对他来说没有用。
相反,基本思想是永远缓存——并在修改文件时更改URL(通常更改文件名),以强制浏览下载新版本。
Because they consider (and it's not a bad idea) that one day is not quite long enough : if you have some user that comes to your website only a couple of times per week, a cache of 1 day will not be useful for him.
Instead, the basic idea is to cache forever -- and to change the URL (changing the name of the file, typically) when a file is modified, to force the browse to download the new version.