0

我有一个 Joomla 站点,在 Apache 服务器上运行,并且在 Firefox 和 Chrome 浏览器缓存页面并且不提供最新版本时遇到问题。

我已将此代码添加到我的 htaccess 文件中:

<IfModule mod_expires.c>
# Enable expirations
ExpiresActive On 
# Default directive
ExpiresDefault "access plus 60 seconds"
# My favicon
ExpiresByType image/x-icon "access plus 1 month"
# Images
ExpiresByType image/gif "access plus 1 week"
ExpiresByType image/png "access plus 1 week"
ExpiresByType image/jpg "access plus 1 week"
ExpiresByType image/jpeg "access plus 1 week"
# CSS
ExpiresByType text/css "access plus 1 week"
# Javascript
ExpiresByType application/javascript "access plus 1 week"
</IfModule>

如果我清除 Chrome 和 Firefox 中的浏览器缓存然后加载站点,我会按照上面的代码获得图像、css 和 javascript 的正确响应标头。

对于主文档,我在第一次加载时得到这些响应标头:

Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Expires: Wed, 17 Aug 2005 00:00:00 GMT
Pragma: no-cache

但是当我重新加载页面甚至在新选项卡中打开它时,那些过期的标题会消失,并且浏览器会加载缓存的网页(状态代码 304 未修改)。

我不知道这里发生了什么。我在 Mac 上使用没有任何这些问题的 Safari,所以我很困惑为什么 Chrome 和 Firefox 的行为不像我期望的那样。

也许可以解释为什么页面有一组与过期相关的响应头而不是 htaccess 中的默认设置。这是 mod_expires 的工作方式吗?

我希望这里有足够的信息来回答我的问题,在此先感谢。

4

1 回答 1

0

这会有所帮助,请参考。通过这个链接

http://php.net/manual/de/function.session-cache-limiter.php

于 2016-12-01T09:26:38.183 回答