首页 > 解决方案 > 如何强制重新加载缓存的 HTML 文件

问题描述

我有一个带有 css 和 html 的简单网站,每次我上传新内容都需要几天时间才能刷新。是否有一行代码强制浏览器重新加载我的代码?我有一个每周更改的 pdf 链接。我不知道是强制使用整个代码还是强制使用 pdf 链接。谢谢

标签: javascripthtmlcsscachingreload

解决方案


Please check the following link: How do we control web page caching, across all browsers?

There are different ways to do that:

If you want to use a htaccess file, add the following line to it:

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

And if you want to just do that in the main html file, add the following to it within the head tag:

<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">

I hope my answer helps you.


推荐阅读