使用 php 新鲜加载页面而不是从缓存中加载
我刚刚将网站的开发版本移植到生产环境中,但它仍然显示旧图像并使用古老的样式表。这发生在每个人身上。
我
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Pragma-directive" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Directive" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="0">
也尝试过,因为这是 WordPress,我只是将 css 排入队列,在末尾添加主题版本。所以 style.css?ver=2.0。
出于公司的需要,我在 IIS 上运行它。
这些选项似乎都不能正常工作。当用户访问该网站时,如何才能重新加载页面而不是从缓存中加载?
I just ported a development version of my site over to production and it's still showing old images and using ancient stylesheets. This is happening to everyone.
I tried
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Pragma-directive" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Directive" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="0">
Also, because this is WordPress I just enqueue the css which adds the theme version at the end. so style.css?ver=2.0.
I'm running this on IIS out of corporate necessity.
None of these options seem to work properly. How can I load the page freshly and not from cache when users visit the site?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
假设你在一个 PHP 页面中,只需在请求中附加一个随机数
你也可以在 CSS/JS/etc 文件中使用 PHP 标头来实现,但是你需要将 CSS 和 JS 解析为 PHP,这会有点麻烦凌乱的。
另一种选择是通过 htaccess 进行设置 - 由 http://www.askapache 提供.com/htaccess/using-http-headers-with-htaccess.html
Assuming you're in a PHP page, just append a random number to the request
You can also do it with PHP headers inside the CSS/JS/etc files, but then you need to parse CSS and JS as PHP and it gets a bit messy.
The other option is to set it up via htaccess - courtesy of http://www.askapache.com/htaccess/using-http-headers-with-htaccess.html
因为它是 WordPress:
尝试 WordPress 的 Style.css Last Version 插件,它可以像魅力一样阻止 CSS 缓存。 https://wordpress.org/plugins/stylecss-load-last-version/
,
Because it's WordPress:
Try the Style.css Last Version plugins for WordPress, it prevents CSS caching like a charm. https://wordpress.org/plugins/stylecss-load-last-version/
Cheers,