javascript - 我如何缓存特定文件 html/css?

标签 javascript html css caching gwt

如何在 html 中缓存特定文件? 我试过了


meta http-equiv="cache-control" content="private" max-age="604800"

但是当我使用谷歌浏览器检查元素点击“审核”时 它给了我

Leverage browser caching (4)
The following resources are missing a cache expiration. Resources that do not specify an expiration may not be cached by browsers:
some.css
some.js
The following resources are explicitly non-cacheable. Consider making them cacheable if possible:
some.html
some-hosted.html

我如何缓存它们?

最佳答案

您的语法无效。

<meta http-equiv="cache-control" content="max-age=604800;private" />

请注意,这不适用于 CSS/JS 或任何其他非 HTML 文件的文件。在这些情况下,您需要在服务器端设置真正的 HTTP header (通常使用网络服务器设置或通过动态服务器端语言(如 PHP、.Net、Coldfusion 等...))。

关于javascript - 我如何缓存特定文件 html/css?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4895337/

相关文章:

c# - 这个json格式正确吗?

javascript - 如何将带有键的对象数组发送到 API?

javascript - 使用 react-testing-library 时如何测试组件是否使用正确的 props 渲染?

css - 分层 <div></div>

javascript - 从数组的值创建数组

javascript - extjs4 类型错误 : store is undefined

python - 从使用 BeautifulSoup 解析的 HTML 中删除标签

javascript - 使用 JQUERY 从 div 元素中检索数据并通过 post 提交

html - 如何在行中 float 元素。

jquery - 延迟更改 css