【问题标题】:User hits mouse back button - browser ignores cache settings?用户点击鼠标后退按钮 - 浏览器忽略缓存设置?
【发布时间】:2010-08-03 19:30:51
【问题描述】:

我需要确保当用户使用鼠标进行回击时,浏览器不会立即从缓存中加载页面,而是再次运行相关代码。

这就是我的 .htaccess 的样子。似乎只是 Firefox 忽略了缓存设置。

<IfModule mod_expires.c>
    ExpiresActive On
#   ExpiresDefault A2630000
    ExpiresByType image/vnd.microsoft.icon "access plus 1 year"
    ExpiresByType image/ico "access plus 1 year"
    ExpiresByType image/gif A2630000
    ExpiresByType image/jpeg A2630000
    ExpiresByType image/png A2630000
    ExpiresByType application/x-javascript M2630000
    ExpiresByType text/css M2630000
</IfModule>

<IfModule mod_headers.c>
    Header set Cache-Control "public"
</IfModule>

#make php scripts uncacheable
<FilesMatch "php">
    Header unset Cache-Control:
    Header append Cache-Control: "no-cache, must-revalidate"
</FilesMatch>

SetOutputFilter DEFLATE

AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/javascript

【问题讨论】:

  • 您能否使用 Firebug 或类似工具确认标头确实已发送?​​

标签: firefox .htaccess caching


【解决方案1】:

在黑暗中拍摄,但标题名称不应该有冒号。试试

<FilesMatch "\.php$">
    Header set Cache-Control "no-cache, must-revalidate"
</FilesMatch>

(我还更改了 FilesMatch 条件以仅匹配 php 扩展名,并删除了 unset/append - set 应该做同样的工作。

【讨论】:

  • 感谢您的回答。我从谷歌搜索中找到的网站复制了该部分,但不知道这是否是正确的方法。但是,它仍然无法在 Firefox 中运行。 Firebug 确实确认标头已设置,但它还在 PageSpeed 的 Status 列下显示“200(缓存)”,这表明资源无论如何都来自缓存?
  • @bcm 200 (cache) 表示根本没有向服务器发出请求。尝试使用此标头值:no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0
  • 谢谢,这似乎成功了,再加上在 Firefox 的明文数据中删除 cookie 和网站首选项。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-10-22
  • 1970-01-01
  • 1970-01-01
  • 2012-02-03
  • 1970-01-01
  • 1970-01-01
  • 2010-11-30
相关资源
最近更新 更多