2017-01-17 58 views
0

我已經在我的wordpress下面的代碼.htacces廣東話利用高速緩存的瀏覽器

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

但是它不工作,即時通訊仍然有很多在谷歌的PageSpeed緩存錯誤。

+0

是什麼在谷歌pagespeed''高速緩存錯誤的意思,正好** **?告訴我們你在看什麼。 –

+0

如果我使用谷歌網頁速度見解測試我的網站,有很多廣告。它說你必須利用以下元素的緩存瀏覽器....它會給我帶來很多帶有.jpg .gif .svg .js擴展名的元素 – romanturbo

回答

1

你的語法是好的。如果它不工作,則不能啓用mod_expires。

  • 啓用指定mod_expires:a2enmod expires
  • 重啓Apache:/etc/init.d/apache2 restart
+0

你是對的,現在它工作了,謝謝您 – romanturbo

0

試試這個:

# Enable browser caching for most static assets, 1 month 
<filesMatch ".(css|jpg|jpeg|png|gif|pdf|js|ico|svg|ttf|woff|woff2)$"> 
Header set Cache-Control "max-age=2592000, public" 
</filesMatch> 

更改max-age你想要的秒數。礦被設置爲1個月。

這使用緩存控制而不是過期。緩存控制是更現代的解決方案。一個很好的概述的差異和如何使用每個在這裏: http://dev.mobify.com/blog/beginners-guide-to-http-cache-headers/

+0

它會產生一個500內部錯誤 – romanturbo