javascript - 如何强制重新加载缓存的 HTML 文件
问题描述
我有一个带有 css 和 html 的简单网站,每次我上传新内容都需要几天时间才能刷新。是否有一行代码强制浏览器重新加载我的代码?我有一个每周更改的 pdf 链接。我不知道是强制使用整个代码还是强制使用 pdf 链接。谢谢
解决方案
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.
推荐阅读
- c# - Xamarin.Forms 中的动态 c# 编译器找不到类型或命名空间
- python - 如何使用通过证书的python请求登录cgi?
- python - 安装 conda 包时出错:conda.core.link:_execute(696):安装包 'conda-forge::qt-5.9.7-h506e8af_3' 时出错
- c++ - 如何在 Oct 文件中使用 C++17 功能
- sql - 如何从 PostgreSQL 的子查询中选择包含值数组的列?
- kubernetes - 如何正确更新作业状态
- javascript - 导出到 Excel:使用 javascript 导出单个单元格中的文本区域内容“在单元格/Alt + Enter 中带有换行符”
- delphi - Delphi SAPI 5.4 播放时冻结表格
- botframework - 如何正确删除或更新 bot 框架上的活动?
- tvos - tvOS 中的 UIButton 图像在按钮获得焦点时被拉伸