I just ran Pagetest and it says I need to set a max-age for my JS/CSS. How do I do that?
Sounds like it's talking about HTTP headers. Basically you'll need to add a couple of HTTP headers to be sent with your Javascript and CSS files (and images too, would be a good idea), looking something like this:
Cache-Control: max-age=86400
Expires: Sat, 28 Mar 2009 16:00:00 GMT
The first one gives the maximum amount of time, in seconds, that a browser will keep the content (the JS or CSS file) before downloading it again from the server; the second one gives the date and time after which the browser should redownload the content. Yes, these are two ways of saying the same thing, but the Cache-Control
header is a little newer and I'm not sure if it's universally supported yet; there's really no harm in specifying both. (Cache-Control
takes precedence over Expires
if there is a conflict.)
As for how you actually configure your server to send these headers: it depends on which web server you're running. If you're using Apache, look at mod_expires.