如何使用 HTML 以编程方式清空浏览器缓存?

htmlweb developmentfront end technology更新于 2026/1/17 18:20:17

您可以使用以下元标记 − 告诉浏览器不要缓存您的页面。

<metahttp-equiv = 'cache-control' content = 'no-cache'>
<metahttp-equiv = 'expires' content = '0'>
<metahttp-equiv = 'pragma' content = 'no-cache'>

此外,请尝试以下操作: 在脚本标记中的文件名后附加一个参数/字符串。当文件更改时,请更改它。

<scriptsrc = "newfile.js?version = 1.0.0"></script>

然后,下次更新文件时,只需更新版本即可。

<scriptsrc = "newfile.js?version = 1.0.1"></script>

相关文章


有用资源