[英]Cant leverage cache browser using wordpress and .htacces
我的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 ##
但是,它不起作用,即時通訊在Google Pagespeed中仍然存在很多緩存錯誤。
您的語法很好。 如果不起作用,則無法啟用mod_expires。
a2enmod expires
/etc/init.d/apache2 restart
嘗試這個:
# 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/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.