2013-08-16 2 views
0

.htaccess 파일에서 캐시 만료 및 gzip 압축을 구성했지만 yslow 크롬 확장 통계에 따라 작동하지 않습니다.Gzip 압축 및 캐시 만료가 작동하지 않습니다.

은 여기 내 htaccess로

# ---------------------------------------------------------------------- 
# Mod Rewrite 
# ---------------------------------------------------------------------- 

<IfModule mod_rewrite.c> 
    Options -MultiViews 
    RewriteEngine On 

    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule^index.php [L] 
</IfModule> 

# ---------------------------------------------------------------------- 
# gZip Compression 
# ---------------------------------------------------------------------- 

<ifModule mod_gzip.c> 
mod_gzip_on Yes 
mod_gzip_dechunk Yes 
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$ 
mod_gzip_item_include handler ^cgi-script$ 
mod_gzip_item_include mime ^text/.* 
mod_gzip_item_include mime ^application/x-javascript.* 
mod_gzip_item_exclude mime ^image/.* 
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.* 
</ifModule> 

# ---------------------------------------------------------------------- 
# Expires headers (for better cache control) 
# ---------------------------------------------------------------------- 

<IfModule mod_expires.c> 
    ExpiresActive on 

# Your document html 
    ExpiresByType text/html "access plus 0 seconds" 

# Media: images, video, audio 
    ExpiresByType audio/ogg "access plus 1 month" 
    ExpiresByType image/gif "access plus 1 month" 
    ExpiresByType image/jpeg "access plus 1 month" 
    ExpiresByType image/png "access plus 1 month" 
    ExpiresByType video/mp4 "access plus 1 month" 
    ExpiresByType video/ogg "access plus 1 month" 
    ExpiresByType video/webm "access plus 1 month" 

# CSS and JavaScript 
    ExpiresByType application/javascript "access plus 1 year" 
    ExpiresByType text/css "access plus 1 year" 
</IfModule> 

주 : 나는 XAMPP

답변

2

사용하고 있는데 이것은 내 첫 번째 게시물은 여기! 캐시 만료를 들어

: 모듈이 "mod_expires.so은"아파치/conf의/httpd.conf 파일에 사용하는 경우

당신이 확인 했습니까? #LoadModule expires_module modules/mod_expires.so 행을 검색하고 "#"기호를 제거하십시오. 그 후에는 효과가 있습니다. gzip 압축을 위해

:

내가 압축을 사용하려면 "mod_deflate를"을 사용합니다. 또한 "mod_mime", "mod_setenvif"및 "mod_headers"를 사용합니다. httpd.conf에서 각각 활성화되어 있는지 확인하십시오. 이 조합은 저에게 효과적입니다.

htaccess로 내 압축 :

<IfModule mod_mime.c> 
AddType application/x-javascript .js 
AddType text/css .css 
</IfModule> 

<IfModule mod_deflate.c> 
SetOutputFilter DEFLATE 
<IfModule mod_setenvif.c> 
    SetEnvIfNoCase Request_URI \.(?:rar|zip)$ no-gzip dont-vary 
    SetEnvIfNoCase Request_URI \.(?:gif|jpg|png)$ no-gzip dont-vary 
    SetEnvIfNoCase Request_URI \.(?:avi|mov|mp4)$ no-gzip dont-vary 
    SetEnvIfNoCase Request_URI \.mp3$ no-gzip dont-vary 
</IfModule> 
<IfModule mod_setenvif.c> 
    BrowserMatch ^Mozilla/4 gzip-only-text/html 
    BrowserMatch ^Mozilla/4\.0[678] no-gzip 
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html 
</IfModule> 
<IfModule mod_headers.c> 
    Header append Vary User-Agent env=!dont-vary 
</IfModule> 
</IfModule> 

더 많은 정보 here. 도움이되기를 바랍니다.