Google Page Speed is telling me to leverage browser caching for only this object:

https://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js (1 hour)

As this is being delivered from an external server, I guess I can't tell browsers to cache it when they visit my site? I am using IIS7 and have already implemented caching for 7 days (as per the config listed here https://stackoverflow.com/questions/642954/iis7-cache-control),

Therefore, should I copy the file to my web server and then reference and cache it on there?

2 Answers 2


Change the URL in your HTML from





  • The opening // instead of https:// is a shorthand -- supported by all major browsers -- which means "the same protocol as the parent page is using". In other words, if your own site uses SSL, then jQuery will be served over SSL. If not, then your users will use plain HTTP for jQuery, and benefit from the faster connection setup un-encrypted HTTP has.

  • When serving content with a full version number -- the 1.6.0 part -- Google's CDN will automatically use long caching headers. The URL you used means "the newest in the 1.6 series", and is served with shorter caching headers, so that Google can quickly update when jQuery releases a new version.

You can verify that this works with Rex Swain's HTTP Viewer if you'd like. (NB: this HTTP viewer doesn't support the // shorthand, but browsers do.)


Two points of view here:

  • Using Google's url you bet on the fact that clients already have the file in their browsers's caches (due to other sites linking the same file).

  • Using your own webserver you can adjust things yourself but you know that every new visitor will have to download the file from you.

That's really an interesting question to think about but I personally prefer to serve the content myself due to the use of expire headers/compression/rewrite rules/etc...

  • 1
    Yes. I would prefer to keep referring to the Google hosted version as that is best practice as clients will probably already have it cached; But it's Google's own Page Speed tool telling me that it should be cached for longer than 1 hour, so just for that reason I am thinking of hosting it myself! :-) Thanks.
    – Techboy
    May 9, 2011 at 14:31

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.