I have already leveraged cache files for common file types. But couldn't get much help on how to add cache expiration for 3rd party API like (Google API) and widgets like (Disqus, AddThis, Pinterest, Twitter) which are slowing my site to 80% (earlier it was 97%)
These are some of the common widgets which are slowing down my site:
- cdn.viglink.com/images/pixel.gif?ch=1&rn=5.711541143245995 (15 seconds)
- cdn.viglink.com/images/pixel.gif?ch=2&rn=5.711541143245995 (15 seconds)
- disqus.com/next/config.js (60 seconds)
- assets.pinterest.com/js/pinit_main.js?0.7067068491596729 (4 minutes)
- s7.addthis.com/js/300/addthis_widget.js (10 minutes)
- m.addthisedge.com/live/boost/ra-9a7a0e60b8044af/_ate.track.config_resp (60 seconds)
- platform.twitter.com/widgets.js (30 minutes)
- apis.google.com/js/api.js (30 minutes)
- apis.google.com/js/rpc:shindig_random.js?onload=init (30 minutes)
This is my .htaccess file
# Leverage Browser Caching
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType text/javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
<IfModule mod_headers.c>
<filesmatch "\.(ico|flv|jpg|jpeg|png|gif|css|swf)$">
Header set Cache-Control "max-age=2678400, public"
</filesmatch>
<filesmatch "\.(html|htm)$">
Header set Cache-Control "max-age=7200, private, must-revalidate"
</filesmatch>
<filesmatch "\.(pdf)$">
Header set Cache-Control "max-age=86400, public"
</filesmatch>
<filesmatch "\.(js)$">
Header set Cache-Control "max-age=2678400, private"
</filesmatch>
</IfModule>