문제

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

세트 쿠키 부분은 정확해 보이지만 만료 헤더는 그렇지 않습니다. 만료를 올바르게 설정하는 방법과 왜 다른가? mod_expires와 mod_headers가 활성화되어 있는지 더 두 번 확인했습니다.

도움이 되었습니까?

해결책

Set-Cookie 헤더에서 이것은 PHP 세션의 일부인 것처럼 보입니다. php는 session_start () 후 캐싱을 자동으로 비활성화합니다.

php.ini에서 session.cache_limiter를 변경 하여이 동작을 수정할 수 있습니다. 보다 PHP 매뉴얼 페이지 다양한 설정의 경우.

또는 "Append"대신 "set"을 사용하여 .htaccess의 헤더를 무시할 수 있습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top