Apache Yslow,Add Expires头不';行不通
因此,我有一个Yslow,我正在尝试添加Expires头 因此,我的网站根目录上有一个Apache Yslow,Add Expires头不';行不通,apache,.htaccess,seo,yslow,Apache,.htaccess,Seo,Yslow,因此,我有一个Yslow,我正在尝试添加Expires头 因此,我的网站根目录上有一个.htaccess: <ifModule mod_expires.c> ExpiresActive On ExpiresDefault "access plus 1 seconds" ExpiresByType text/html "access plus 1 seconds" ExpiresByType image/gif "access plus 2592000 seconds"
.htaccess
:
<ifModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 seconds"
ExpiresByType text/html "access plus 1 seconds"
ExpiresByType image/gif "access plus 2592000 seconds"
ExpiresByType image/jpeg "access plus 2592000 seconds"
ExpiresByType image/png "access plus 2592000 seconds"
ExpiresByType text/css "access plus 604800 seconds"
ExpiresByType text/javascript "access plus 216000 seconds"
ExpiresByType application/x-javascript "access plus 216000 seconds"
ExpiresByType application/javascript "access plus 216000 seconds"
</ifModule>
<ifModule mod_headers.c>
<filesMatch "\\.(ico|pdf|flv|jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=2592000, public"
</filesMatch>
<filesMatch "\\.(css)$">
Header set Cache-Control "max-age=604800, public"
</filesMatch>
<filesMatch "\\.(js)$">
Header set Cache-Control "max-age=216000, private"
</filesMatch>
<filesMatch "\\.(xml|txt)$">
Header set Cache-Control "max-age=216000, public, must-revalidate"
</filesMatch>
<filesMatch "\\.(html|htm|php)$">
Header set Cache-Control "max-age=1, private, must-revalidate"
</filesMatch>
</ifModule>
但没有效果,我总是用“F”和Yslow。。。我能为此做些什么?我已经阅读了stackoverflow的其他主题
谢谢 当遇到类似问题时,下面的链接帮助我在Apache上设置expires头
.
在httpd.conf中的项目配置中的文档模块中添加ExpiresActive On之前和ExpiresByType,我就成功了。 也许这对你也有帮助。
此外,我不需要向标头添加缓存控制。它们会自动添加到标题中。我不是职业选手,但这是我观察到的
root@heisenberg:~# a2enmod headers
Module headers already enabled
root@heisenberg:~# a2enmod expires
Module expires already enabled