如何添加Expires标头

时间:2016-08-01 07:30:32

标签: wordpress .htaccess expires-header w3-total-cache

我在.htaccess中使用此代码

<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 1 month"
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"
ExpiresByType text/html "access plus 3 days"
ExpiresByType text/xml "access plus 1 seconds"
ExpiresByType text/plain "access plus 1 seconds"
ExpiresByType application/xml "access plus 1 seconds"
ExpiresByType application/rss+xml "access plus 1 seconds"
ExpiresByType application/json "access plus 1 seconds"
ExpiresByType text/css "access plus 1 week"
ExpiresByType text/javascript "access plus 1 week"
ExpiresByType application/javascript "access plus 1 week"
ExpiresByType application/x-javascript "access plus 1 week"
ExpiresByType image/x-ico "access plus 1 year"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresByType application/pdf "access plus 1 month"
<IfModule mod_headers.c>
   Header unset ETag
   Header unset Pragma
   Header unset Last-Modified
   Header append Cache-Control "public, no-transform, must-revalidate"
   Header set Last-modified "Tue, 1 Aug 2016 10:10:10 GMT"
 </IfModule>
 </IfModule>

但gtmetrix.com和tools.pingdom.com显示5个静态组件,没有远期到期日。

http://fonts.googleapis.com/css?family=Lato:900
http://fonts.googleapis.com/css?family=Merriweather:regular,700
http://www.google-analytics.com/analytics.js
http://www.statcounter.com/counter/counter.js
http://c.statcounter.com/t.php?sc_project=11059157&java=1&security=2d5e45b2&u1=D82D61ABF18A4FF9620A96B3F31C97F5&sc_random=0.5705474616082253&jg=new&rr=1.1.1.1.1.1.1.1.1&resolution=1024&h=861&camefrom=&u=http%3A//hddregenerator.net/&t=HDD%20REGENERATOR.%2015%25%20Discount%20%7C%20HDD%20Regenerator%20for%20%2484.99.%20Free%20Demo%20download.%2030-day%20money%20back%20guarantee.%20Free%201%20year%20minor%20update.%20Unlimited%20license%20period.&rcat=d&rdom=d&rdomg=new&bb=1&sc_snum=1&sess=a181b5&p=0&invisible=1

如何为这5个组件添加过期标题?!

1 个答案:

答案 0 :(得分:1)

我相信您无法为这5个组件添加过期标头,只是因为它们不在您自己的服务器上,因此您无法控制它们。

如果您正在寻找一个出色的过期标题插件,我建议Far Future Expiry Header