2013-05-17 92 views
2

我使用webpagetest知道我的網站performance.I我發現緩存靜態內容,即「靜態資產的槓桿瀏覽器緩存:88/100」的問題提高網站的性能緩存靜態內容問題

失敗 - (無最大值-age or expires)

我該如何解決這個問題?

我htaccess的樣子:

# compress text, html, javascript, css, xml: 
AddOutputFilterByType DEFLATE text/plain 
AddOutputFilterByType DEFLATE text/html 
AddOutputFilterByType DEFLATE text/xml 
AddOutputFilterByType DEFLATE text/css 
AddOutputFilterByType DEFLATE application/xml 
AddOutputFilterByType DEFLATE application/xhtml+xml 
AddOutputFilterByType DEFLATE application/rss+xml 
AddOutputFilterByType DEFLATE application/javascript 
AddOutputFilterByType DEFLATE application/x-javascript 
AddOutputFilterByType DEFLATE image/svg+xml 
AddOutputFilterByType DEFLATE image/png 
AddOutputFilterByType DEFLATE image/jpg 
AddOutputFilterByType DEFLATE image/gif 

# Or, compress certain file types by extension: 
<ifModule mod_deflate.c> 
<filesMatch ".(js|css|html|htm|php|jpg|jpeg|woff|eot)$"> 
SetOutputFilter DEFLATE 
</FilesMatch> 
</ifModule> 

# Direct Apache to send all HTML output to the mod_pagespeed output handler. 
AddOutputFilterByType MOD_PAGESPEED_OUTPUT_FILTER text/html 

感謝

回答

0

除了放氣的設置,要添加一些到期的控制來管理瀏覽器緩存。我已經使用了以下結果。根據您網站上文件的具體情況,您可能還需要添加音頻和視頻文件。

從內存中,webpagetest喜歡它,當你到期設置至少1個月,所以你可能也想了調整1周設置

祝你好運!

################ 
# Enable expiration control 
ExpiresActive On 

# Default expiration: 1 hour after request 
ExpiresDefault "now plus 1 hour" 

# CSS and JS expiration: 1 week after request 
ExpiresByType text/css "now plus 1 week" 
ExpiresByType application/javascript "now plus 1 week" 
ExpiresByType application/x-javascript "now plus 1 week" 

# Image files expiration: 1 month after request 
ExpiresByType image/bmp "now plus 1 month" 
ExpiresByType image/gif "now plus 1 month" 
ExpiresByType image/jpeg "now plus 1 month" 
ExpiresByType image/jp2 "now plus 1 month" 
ExpiresByType image/pipeg "now plus 1 month" 
ExpiresByType image/png "now plus 1 month" 

########## End - Optimal expiration time 
+0

我試過,但得到同樣的味精「靜態資產的槓桿瀏覽器緩存:77/100」 失敗 - (無最大年齡或到期) – user2393759

+0

如果您張貼網站的URL我可以看看它的一些更適合你。 –

+0

http://www.tradesmartonline.in/ – user2393759

0
ExpiresActive on 
ExpiresDefault "access plus 1 month" 
ExpiresByType text/html "now plus 0 second" 
<FilesMatch "\.(css|js|png|bmp|ico|htm|gff|html|js|jpg|jpeg|gif|gcf)$"> 
FileETag MTime Size 
ExpiresDefault "access plus 1 month" 
</FilesMatch> 

這裏是我的主機我在.htaccess中緩存改變之後所控制。但即使我改變了這些,但運行webpagetest.org時似乎並沒有什麼好的效果。我需要等到先前的緩存過期並再次運行它。這行得通。歡呼! 。這裏我找到了一個有用的鏈接。 http://httpd.apache.org/docs/current/mod/mod_expires.html