4

I am using different plugins in WordPress like Disqus comment system, Theia Post slider and other.. Here is a result from GTmatrix :

Result from gtmetrix.com

I want to know how can I add expiry header on third party JS files and CSS files. I want to increase my Y-Slow grade.

2
  • 2
    Better look at your requests, 128 is ridiculous. That should not be more that 50 which is already going to the high side – Pieter Goosen Apr 13 '15 at 6:51
  • 1
    You can't add expiry header on thirdparty JS and CSS file unless you host them yourself. – Robert hue Apr 13 '15 at 12:20
1

As Robert mentioned in comments, you can't add any additional headers (Expires, Cache-Control, etc.) to any resources (JS, CSS, images, etc.) that are hosted and served by a third party, unless you have direct control of that third party in order to do so. Perhaps if the third party offers this as a feature.

You can only add additional HTTP response headers to resources that you are directly serving from your site.

However, there is a "theoretical workaround". You can potentially configure part of your site as a proxy (or temporary store for these external resources). For example, the links to these third party files are changed to point to your site. Your server then makes a "proxy" request to the third party resource which is sent back to your server and your server then sends this back to the client, with any additional HTTP response headers (eg. Expires) you might want to set. However, this is non-trivial, a potential security hole if done incorrectly and may not be possible anyway if the entire tool is hosted externally, as is the case with Disqus.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy