1

I wanted to set up caching on all the junk my webserver serves, but I would like a good idea of what production-level services use cache wise? For some reason I can't pick my own times for things like js, css, png, jpg, etc.

1 Answer 1

1

The exact method used to set the cache headers varies depending on which web server you're using.

In IIS 6, for example, you can right-click on any folder or file from within the IIS management console, select Properties, and set the content expiration however long you like (under the HTTP Headers tab).

In IIS7 select the folder (or file from the content view), and open the "HTTP Response Headers" module. From the actions pane, select "Set Common Headers..." and activate content expiration.

I generally group different types of files under different folders. The CSS files would be in a styles folder, images go in an images folder, etc. You can set different expiration times for each of these folders. For CSS you might set it to a few days. JavaScript might be a week. For images I usually select anywhere from 7 to 30 days depending on the site. You should select your own expiration times based on how often the site is updated.

2
  • The problem we often have with setting huge cache times on javascript files, is if there's a small bug fix that you push live hundreds of users are often left with stale cache's Nov 23, 2010 at 22:55
  • If you make a change to the file and want it reloaded immediately, you can alter the call in HTML to add a meaningless query parameter to it, such as src="/scripts/script.js?rev=2 to trick the browser into thinking it's a different file and it will reload because of the updated URL. Nov 25, 2010 at 2:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .