Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.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
Apache 设置Cookie和Expires标头不同_Apache_.htaccess_Yslow_Mod Expires - Fatal编程技术网

Apache 设置Cookie和Expires标头不同

Apache 设置Cookie和Expires标头不同,apache,.htaccess,yslow,mod-expires,Apache,.htaccess,Yslow,Mod Expires,我正在尝试按照YSlow的建议为图像启用Expires头。我肯定我以前有过这个功能,但现在当我检查YSlow时,它说它们没有被缓存 对于我的.htaccess,我已尝试: ExpiresActive on ExpiresDefault A0 <FilesMatch "\.(gif|ico|jpg|png)$"> ExpiresDefault A29030400 Header append Cache-Control "public" </FilesMatch&g

我正在尝试按照YSlow的建议为图像启用Expires头。我肯定我以前有过这个功能,但现在当我检查YSlow时,它说它们没有被缓存

对于我的.htaccess,我已尝试:

ExpiresActive on
ExpiresDefault A0
<FilesMatch "\.(gif|ico|jpg|png)$">
    ExpiresDefault A29030400
    Header append Cache-Control "public"
</FilesMatch>
为我的一个图像输出以下内容:

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_header是否已启用。

从Set Cookie header中,看起来这是php会话的一部分。php在会话启动()后自动禁用缓存

您可以通过更改php.ini中的session.cache\u limiter来修改此行为。有关各种设置,请参见


或者,您可以尝试使用“set”而不是“append”来覆盖.htaccess中的标题。

该站点使用内部框架,该框架存储公共html目录之外的所有内容,并提供来自PHP脚本的图像。我将图像移动到public_html/img,并且.htaccess设置工作正常。
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