Php htaccess浏览器缓存不工作
我的.htaccess文件忽略了整个浏览器缓存内容。我在同一台服务器上有多个域,在其中一个域中,相同的代码可以正常工作。我的测试工具是 如果我使用Php htaccess浏览器缓存不工作,php,apache,.htaccess,caching,cache-control,Php,Apache,.htaccess,Caching,Cache Control,我的.htaccess文件忽略了整个浏览器缓存内容。我在同一台服务器上有多个域,在其中一个域中,相同的代码可以正常工作。我的测试工具是 如果我使用标题手动设置缓存控制(“缓存控制:max age=2592000”)HTTP头看起来不错,但仍忽略.htaccess中的浏览器缓存规则 我不明白为什么缓存控件默认使用无存储,无缓存,…,我可以在哪里更改它。此外,我注意到mod_header模块没有列在我的phpinfo()输出中,并且FileMatch标记会在没有ifModule mod_header
标题手动设置缓存控制(“缓存控制:max age=2592000”)代码>HTTP头看起来不错,但仍忽略.htaccess中的浏览器缓存规则
我不明白为什么缓存控件默认使用无存储,无缓存,…
,我可以在哪里更改它。此外,我注意到mod_header模块没有列在我的phpinfo()
输出中,并且FileMatch
标记会在没有ifModule mod_header
检查的情况下导致内部服务器错误。但如果这就是问题所在,为什么同一个脚本在另一个域上工作
非常感谢
2017年6月21日起编辑:
我忘了说我们正在使用CDN(Cloudflare)。我用REDbot分析了更多的头,缓存控制似乎是正确的(png,Cache-Control:public,max-age=2592000
)。在我的WebGetTest结果中,它始终显示警告-(4.0小时)-(…).png
。不是CDN覆盖了头,就是测试结果错了 您启用expire模块了吗?mod_expires
模块在我的phpinfo()输出中的“已加载模块”列表中。
<IfModule mod_filter.c>
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css text/javascript
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript application/x-javascript
AddType image/svg+xml .svg
AddOutputFilterByType DEFLATE image/svg+xml
</IfModule>
</IfModule>
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 12 hours"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType text/html "access plus 4 hours"
ExpiresByType text/htm "access plus 4 hours"
ExpiresByType text/javascript "access plus 5 days"
ExpiresByType text/x-javascript "access plus 5 days"
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/xml "access plus 2 days"
ExpiresByType application/xml "access plus 0 seconds"
ExpiresByType application/json "access plus 0 seconds"
ExpiresByType text/cache-manifest "access plus 0 seconds"
</IfModule>
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache