样板缓存清除问题

发布于 2024-10-07 21:27:06 字数 289 浏览 1 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

(り薆情海 2024-10-14 21:27:06

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 to www.example.com/?v=2 the browser does not recognize this url so it doesn't use any cached files. When a user goes back to www.example.com/?v=2 it will access the cached files for v2 of your website

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文