样板缓存清除问题
1)我对设置标头到期日期的目的感到困惑 用于缓存 css 和 js 文件(就像在 样板 .htaccess 文件)。
我认为网络浏览器会自动缓存 css 和 js 文件。 设置标头到期日期有什么意义?
2)有没有办法不使用 css 和 js 文件的版本控制 当我将它们上传到服务器时,它们仍然会自动更新。 我尝试设置较低的到期日期(“访问加 1 周”和“访问 加 0 秒”)并且浏览器仍然显示旧的缓存副本 当我上传更新的 css 和 js 文件时。我不能 100% 确定我做了这件事 不过,正确的是。
谢谢 :)
1) I'm confused about the purpose of setting header expiry dates
for caching css and js files (like how it's done in the
Boilerplate .htaccess file).
I thought web browsers automatically cache css and js files.
What's the point of setting header expiry dates?
2) Is there a way to NOT use versioning of css and js files and
still have them automatically update when I upload them to a server.
I tried setting a lower expiry date ("access plus 1 week" and "access
plus 0 seconds") and the browser was still displaying the old cached copy
when I uploaded updated css and js files. I'm not 100% sure I did this
correctly, though.
Thanks :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
1) 有些浏览器不会缓存没有过期日期的内容。
2) 尝试将 get 变量附加到新版本网站的 URL 字符串末尾,以忽略以前版本的缓存。这个想法是将您的网址字符串转换为类似
www.example.com/?v=1
的内容,然后将其更改为www.example.com/?v=2
> 浏览器无法识别此网址,因此不会使用任何缓存文件。当用户返回www.example.com/?v=2
时,它将访问您网站v2
的缓存文件1) Some browsers don't cache things that do not have an expiration date.
2) Try appending a get variable to the end of your URL string to new versions of your website to ignore previous versions cache. The idea is to transform your urlstring into something like
www.example.com/?v=1
and then when you change that towww.example.com/?v=2
the browser does not recognize this url so it doesn't use any cached files. When a user goes back towww.example.com/?v=2
it will access the cached files forv2
of your website