如何在所有浏览器中控制网页缓存?

发布于 2025-01-24 16:52:04 字数 425 浏览 2 评论 0原文

我有一个网站启动并运行;我一直在努力改进网站。但是,除非Codumer Presse 清除缓存它不会更新到我的CSS和HTML的最新版本。我想更改使用

HTML的

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">

HTTP高速缓存标头,因此网站始终拥有所有当前信息。

但是我不知道将此代码放在哪里。我创建一个名为html的新文件,还是我只是在index.html的某个地方输入此文件。请帮忙。

I have a website up and running; I am constantly working on improving the site. But unless the costumer presse clears the cache it does not update to the latest version of my css and html. I wanted to change the http cache header to be

USING HTML

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">

So this way the website has all the current info at all time.

But I have no idea as to where to put this code in. Do I create a new file named html or do I just input this somewhere in my index.html. Please help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

你曾走过我的故事 2025-01-31 16:52:04

您可以将META标签放入HTML文件的Head标签中,但是如果HTTP响应中存在标头,则比优先级优先于Meta标签。如果您使用的是Apache,则创建.htaccess文件并将标题设置在此处以防止缓存

<IfModule mod_headers.c>
    Header set Cache-Control "no-cache, no-store, must-revalidate"
    Header set Pragma "no-cache"
    Header set Expires 0
</IfModule>

You can put meta tag inside the head tag of your html file but if header is present in http response than that takes priority over meta tag. If you are using apache then create .htaccess file and set header there to prevent caching

<IfModule mod_headers.c>
    Header set Cache-Control "no-cache, no-store, must-revalidate"
    Header set Pragma "no-cache"
    Header set Expires 0
</IfModule>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文