2016-09-24 42 views
2

我有joomla網站,並添加了.htaccess文件來優化它使用gzip,deflate添加到期過濾器。我正在使用網頁速度來分析它正在改進的程度。但無論我添加.htaccess文件或者沒有網頁速度點保持相同htaccess代碼沒有優化網站的性能Joomla

我的意思是說增加壓縮和過濾器爲.htaccess應該提高,但它沒有這樣做,即使我刪除.htaccess文件的網站工作正常和pagespeed指標點保持不變。下面是我的.htaccess文件的代碼

爲了檢查,如果我把錯誤的標籤,如「這是我的.htaccess」在.htaccess文件然後站點提供了500個錯誤

## Can be commented out if causes errors, see notes above. 

Options +FollowSymLinks 
<ifModule mod_gzip.c> 
mod_gzip_on Yes 
mod_gzip_dechunk Yes 
mod_gzip_item_include file .(html?|txt|css|js|php|pl|png|gif|jpg)$ 
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> 
# 480 weeks 
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$"> 
Header set Cache-Control "max-age=7200, public" 
</FilesMatch> 

# 2 DAYS 
<FilesMatch "\.(xml|txt)$"> 
Header set Cache-Control "max-age=172800, public, must-revalidate" 
</FilesMatch> 

# 2 HOURS 
<FilesMatch "\.(html|htm)$"> 
Header set Cache-Control "max-age=7200, must-revalidate" 
</FilesMatch> 


# BEGIN EXPIRES 
<IfModule mod_expires.c> 
    ExpiresActive On 
    ExpiresDefault "access plus 1 seconds" 
    ExpiresByType text/html "access plus 600 seconds" 
    ExpiresByType application/xhtml+xml "access plus 600 seconds" 
    ExpiresByType text/css "access plus 1 month" 
    ExpiresByType text/javascript "access plus 1 month " 
    ExpiresByType application/javascript "access plus 1 month" 
    ExpiresByType application/x-javascript "access plus 1 month" 
    ExpiresByType image/x-icon "access plus 1 year" 
    ExpiresByType image/jpeg "access plus 1 year" 
    ExpiresByType image/png "access plus 1 year" 
    ExpiresByType image/gif "access plus 1 year" 
</IfModule> 

# END EXPIRES 

<IfModule mod_headers.c> 
    # Serve gzip compressed CSS files if they exist 
    # and the client accepts gzip. 
    RewriteCond "%{HTTP:Accept-encoding}" "gzip" 
    RewriteCond "%{REQUEST_FILENAME}\.gz" -s 
    RewriteRule "^(.*)\.css" "$1\.css\.gz" [QSA] 

    # Serve gzip compressed JS files if they exist 
    # and the client accepts gzip. 
    RewriteCond "%{HTTP:Accept-encoding}" "gzip" 
    RewriteCond "%{REQUEST_FILENAME}\.gz" -s 
    RewriteRule "^(.*)\.js" "$1\.js\.gz" [QSA] 
</IfModule> 

<IfModule mod_deflate.c> 
    # Compress HTML, CSS, JavaScript, Text, XML and fonts 
    AddOutputFilterByType DEFLATE application/javascript 
    AddOutputFilterByType DEFLATE application/rss+xml 
    AddOutputFilterByType DEFLATE application/vnd.ms-fontobject 
    AddOutputFilterByType DEFLATE application/x-font 
    AddOutputFilterByType DEFLATE application/x-font-opentype 
    AddOutputFilterByType DEFLATE application/x-font-otf 
    AddOutputFilterByType DEFLATE application/x-font-truetype 
    AddOutputFilterByType DEFLATE application/x-font-ttf 
    AddOutputFilterByType DEFLATE application/x-javascript 
    AddOutputFilterByType DEFLATE application/xhtml+xml 
    AddOutputFilterByType DEFLATE application/xml 
    AddOutputFilterByType DEFLATE font/opentype 
    AddOutputFilterByType DEFLATE font/otf 
    AddOutputFilterByType DEFLATE font/ttf 
    AddOutputFilterByType DEFLATE image/svg+xml 
    AddOutputFilterByType DEFLATE image/x-icon 
    AddOutputFilterByType DEFLATE text/css 
    AddOutputFilterByType DEFLATE text/html 
    AddOutputFilterByType DEFLATE text/javascript 
    AddOutputFilterByType DEFLATE text/plain 
    AddOutputFilterByType DEFLATE text/xml 
</IfModule> 

## EXPIRES CACHING ## 
<IfModule mod_expires.c> 
ExpiresActive On 
ExpiresByType image/jpg "access plus 1 year" 
ExpiresByType image/jpeg "access plus 1 year" 
ExpiresByType image/gif "access plus 1 year" 
ExpiresByType image/png "access plus 1 year" 
ExpiresByType text/css "access plus 1 month" 
ExpiresByType application/pdf "access plus 1 month" 
ExpiresByType text/x-javascript "access plus 1 month" 
ExpiresByType application/x-shockwave-flash "access plus 1 month" 
ExpiresByType image/x-icon "access plus 1 year" 
ExpiresDefault "access plus 2 days" 
</IfModule> 
## EXPIRES CACHING ## 

回答

0

我的猜測是,有是導致你的分數保持在較低水平的更大問題。這些問題可能包括:非常大且未優化的圖像,導致網站速度慢的高負載服務器以及JavaScript/CSS文件排序。

另一個原因可能是您使用的服務器上可能不存在mod_gzip。在這種情況下,你應該使用mod_deflate,所以你應該mod_deflate取代mod_gzip,所以這行:

<ifModule mod_gzip.c> 

應該是:

<ifModule mod_deflate.c> 
+0

如果你檢查我的代碼,我已經添加了mod_deflate.c – Steve

0

只要把下面的代碼htaccess的

<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> 

<IfModule mod_expires.c> 
# Enable expirations 
ExpiresActive On 
# Default directive 
ExpiresDefault "access plus 1 month" 
# My favicon 
ExpiresByType image/x-icon "access plus 1 year" 
# Images 
ExpiresByType image/gif "access plus 1 month" 
ExpiresByType image/png "access plus 1 month" 
ExpiresByType image/jpg "access plus 1 month" 
ExpiresByType image/jpeg "access plus 1 month" 
# CSS 
ExpiresByType text/css "access plus 1 month" 
# Javascript 
ExpiresByType application/javascript "access plus 1 year" 
</IfModule> 

<IfModule mod_deflate.c> 
    # Compress HTML, CSS, JavaScript, Text, XML and fonts 
    AddOutputFilterByType DEFLATE application/javascript 
    AddOutputFilterByType DEFLATE application/rss+xml 
    AddOutputFilterByType DEFLATE application/vnd.ms-fontobject 
    AddOutputFilterByType DEFLATE application/x-font 
    AddOutputFilterByType DEFLATE application/x-font-opentype 
    AddOutputFilterByType DEFLATE application/x-font-otf 
    AddOutputFilterByType DEFLATE application/x-font-truetype 
    AddOutputFilterByType DEFLATE application/x-font-ttf 
    AddOutputFilterByType DEFLATE application/x-javascript 
    AddOutputFilterByType DEFLATE application/xhtml+xml 
    AddOutputFilterByType DEFLATE application/xml 
    AddOutputFilterByType DEFLATE font/opentype 
    AddOutputFilterByType DEFLATE font/otf 
    AddOutputFilterByType DEFLATE font/ttf 
    AddOutputFilterByType DEFLATE image/svg+xml 
    AddOutputFilterByType DEFLATE image/x-icon 
    AddOutputFilterByType DEFLATE text/css 
    AddOutputFilterByType DEFLATE text/html 
    AddOutputFilterByType DEFLATE text/javascript 
    AddOutputFilterByType DEFLATE text/plain 
    AddOutputFilterByType DEFLATE text/xml 

    # Remove browser bugs (only needed for really old browsers) 
    BrowserMatch ^Mozilla/4 gzip-only-text/html 
    BrowserMatch ^Mozilla/4\.0[678] no-gzip 
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html 
    Header append Vary User-Agent 
</IfModule> 

# BEGIN Cache-Control Headers 
<ifModule mod_headers.c> 
    <filesMatch ".(ico|jpe?g|png|gif|swf)$"> 
    Header set Cache-Control "public" 
    </filesMatch> 
    <filesMatch ".(css)$"> 
    Header set Cache-Control "public" 
    </filesMatch> 
    <filesMatch ".(js)$"> 
    Header set Cache-Control "private" 
    </filesMatch> 
    <filesMatch ".(x?html?|php)$"> 
    Header set Cache-Control "private, must-revalidate" 
    </filesMatch> 
</ifModule> 
# END Cache-Control Headers 

# BEGIN Turn ETags Off 
FileETag None 
# END Turn ETags Off