我试图使过期为图像标头所推荐的YSlow的。我敢肯定,我有过这方面的工作,但现在当我检查的YSlow,它说他们没有被缓存。

有关我的。htaccess,我曾尝试:

ExpiresActive on
ExpiresDefault A0
<FilesMatch "\.(gif|ico|jpg|png)$">
    ExpiresDefault A29030400
    Header append Cache-Control "public"
</FilesMatch>

ExpiresActive on
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 month"

http://www.seoconsultants.com/tools/headers.asp 输出搜索我的图像中的一个的以下内容:

HTTP Status Code: HTTP/1.1 200 OK
Date: Mon, 05 Oct 2009 20:12:04 GMT
Server: Apache/2.0.63 (Unix) mod_ssl/2.0.63 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4 PHP/5.2.8
X-Powered-By: PHP/5.2.8
Set-Cookie: PHPSESSID=5d11f4d8aa37ceee6605786e59ff4f0f; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: lastlogin=1254773024; expires=Mon, 02-Nov-2009 20:12:04 GMT
Connection: close
Content-Type: image/jpeg

在的Set-Cookie部分看起来正确的,但Expires头部却不是。如何设置过期时间正确,以及为什么它们有什么不同?我有双重检查该指定mod_expires mod_headers中和启用。

有帮助吗?

解决方案

在Set-Cookie头,它看起来像,这是一个php会话的一部分。 PHP一个在session_start之后自动禁用高速缓存()。

您可以通过在你的php.ini改变session.cache_limiter修改此行为。请参见 PHP手册页各种设置。

另外,你可以尝试使用“设置”,而不是“追加”重写头在你的.htaccess。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top