Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

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.

share|improve this answer
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 – Mark Henderson Nov 23 '10 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. – Justin Scott Nov 25 '10 at 2:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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