Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/253.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 利用浏览器缓存-未设置到期日期_Php_.htaccess_Caching_Browser Cache - Fatal编程技术网

Php 利用浏览器缓存-未设置到期日期

Php 利用浏览器缓存-未设置到期日期,php,.htaccess,caching,browser-cache,Php,.htaccess,Caching,Browser Cache,我正在使用,它表明我的站点上的每个图像都没有被缓存。我已尝试使用W3 Total Cache编辑.htaccess,并使用以下内容: ## EXPIRES CACHING ## <IfModule mod_expires.c> ExpiresActive On ExpiresByType image/jpg "access 1 year" ExpiresByType image/jpeg "access 1 year" ExpiresByType image/gif "access

我正在使用,它表明我的站点上的每个图像都没有被缓存。我已尝试使用W3 Total Cache编辑.htaccess,并使用以下内容:

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
## EXPIRES CACHING ##
##过期缓存##
过期于
过期按类型映像/jpg“访问1年”
过期按类型图像/jpeg“访问1年”
ExpiresByType image/gif“访问1年”
过期按类型图像/png“访问1年”
ExpiresByType文本/css“访问1个月”
ExpiresByType text/html“访问1个月”
过期按类型应用程序/pdf“访问1个月”
ExpiresByType文本/x-javascript“访问1个月”
过期按类型应用程序/x-shockwave-flash“访问1个月”
过期按类型图像/x图标“访问1年”
ExpiresDefault“访问1个月”
##过期缓存##
这是:

<filesMatch ".(ico|pdf|flv|jpg|svg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=84600, public"
</filesMatch> 

标题集缓存控制“最大年龄=84600,公共”
代码,但没有用。 为什么图像没有被缓存?有办法解决这个问题吗

指向PageSpeed的链接:


提前谢谢你

您需要添加单词
plus
,以使其正常工作

否则,您所说的
将在其被访问一个月后过期
。这毫无意义

ExpiresActive On
ExpiresDefault "access plus 14 days"
ExpiresByType application/javascript "access plus 30 days"
ExpiresByType text/css "access plus 30 days"
ExpiresByType application/x-httpd-php "access plus 30 seconds"

你能至少给我们看一下扫描的结果吗,或者给我们看一下网站什么的吗?是的。您可能甚至没有加载mod_expires模块?这就是我的.htaccess文件目前的样子,但它仍然无法工作。我是否仍在做一些错误的事情,或者某个插件可能会干扰,比如自动优化?顺便说一下,我正在使用Wordpress CMS。没关系。我想你可能是对的,mod_过期未加载。我只是不知道我能不能检查一下。无论如何,非常感谢:)只需去掉expires调用的
部分和
部分,然后重新加载页面——如果您的网站未加载,则不会加载mod_expires;)还要确保在httpd.conf中为虚拟主机设置了AllowOverrides