How to Add Expires headers

18,159

I believe you can't add expire headers to those 5 components, simply because they aren't on your own server, and therefore you have no control over them.

If you're looking for a great expire headers plugin, I recommend Far Future Expiry Header.

Share:
18,159
Merkucio
Author by

Merkucio

Updated on November 30, 2022

Comments

  • Merkucio
    Merkucio over 1 year

    I'm using this code in .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>
    

    But gtmetrix.com and tools.pingdom.com shows 5 static components without a far-future expiration date.

    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
    

    How to add expire headers for these 5 components?!

    • Pardeep Pathania
      Pardeep Pathania over 7 years
      you can use one of the plugin for same W3 Total Cache WP Super Cache WP Rocket
    • Merkucio
      Merkucio over 7 years
      I use the total cash but get the message about the expires header anyway.
    • Pardeep Pathania
      Pardeep Pathania over 7 years
      try to install WP Super Cache
    • Ankit Agrawal
      Ankit Agrawal over 5 years
      Hello @Merkucio, I am facing the same issue. Did you find a solution for this? I am already using the WP Super Cache plugin.
    • Merkucio
      Merkucio over 5 years
      Hello. No, I didn't.