7

In my never ending quest for a faster website, I thought perhaps I could cache some scripts. I'm using Yslow to rate my site, everything is pretty much A (which is great, our website on Pingdom loads in 0.4-0.6 seconds which is 5-20x quicker than our competitors) except two things:

Add expire headers:

(2011/7/7) http://fonts.googleapis.com/css?...
(2011/7/6) http://fonts.googleapis.com/css?...
(no expires) http://s7.addthis.com/js/250/addthis_widget.js#pubid=ra-4d7a205f1e2a0b4b

And too many DNS lookups:

The components are split over more than 4 domains

static1.scirra.net: 4 components, 19.3K (4.3K GZip)

fonts.googleapis.com: 2 components, 0.8K (0.5K GZip)

static3.scirra.net: 2 components, 5.5K (2.7K GZip)

static4.scirra.net: 3 components, 12.7K

static2.scirra.net: 3 components, 76.6K

s7.addthis.com: 3 components, 126.3K (40.4K GZip)

ajax.googleapis.com: 1 component, 78.6K (27.1K GZip)

www.scirra.com: 1 component, 8.0K (3.3K GZip)

This answer on SO:

https://stackoverflow.com/questions/1439042/how-can-i-add-expire-headers-for-scripts-that-are-not-on-my-server/1439128#1439128

Suggests having an intermediatory caching script, which fetches these and serves them from your own server.

Thoughts? If you're a speed nut like me can we expect to shave some loading time off for the users at the expense of our bandwidth?

1
  • 2
    Note: there is a tradeoff if you cache them locally on your server... as you increase the load on your own server for those files when un-cached, and reduce the pipelining abilities of the browser by moving the scripts from a CDN developer.yahoo.com/performance/rules.html#cdn back onto your local server.
    – scunliffe
    Jul 7, 2011 at 17:18

2 Answers 2

8

Moving unique static files to your own domain to reduce domain lookups and control expire headers is a good idea, provided you're prepared to check the master files for changes periodically.

Moving common static files to your own domain is not always a good idea, because you lose the benefit if they're already cached from another site the user may have visited. (e.g. Google Web Fonts and the JavaScript files hosted within the Google Libraries API.)

[Aside: To my knowledge, pingdom measures server response time, not page load time, but 0.6 seconds still sounds fast!]

4

Bandwidth is almost a commodity at this point. Especially if you're compressing your files before sending them to the user. And since page speed has been proven to affect not only search rankings but, more importantly, conversion rates, I would say this is not a bad strategy to employ. Just make sure your caching engine accounts for updates to any of the external scripts you are caching. Being out of sync with them may cause undesirable results.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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