Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How can I check if a website is being cached correctly?

I would like the webpages to be cached by browsers, but I also would like that page updates be visible immediatly when a user visits teh webpage (eg not after a forced reload of the page), so no user ever gets to see stale content.

I'm a bit at a loss here on how to set the headers correctly (using nginx or set them using php...) and I would like to play around with them a bit but I have no clue on how to debug this kind of stuff. so far I've been checking with curl if the headers at least look as expected, but this doesn't indicate if the behaviour will also be as expected..

share|improve this question
    
This may be more appropriate for webmasters.SE, but check the FAQ and previous questions before asking. –  mgorven Feb 20 '13 at 17:43

2 Answers 2

Google has created some nice documents that are talking about this: Optimize Caching and HTTP Caching.

Basically you put a short expiration date for dynamically generated pages and for static stuff, like files and images, you put a very long expiration time, but you never replace them. If you need to replace static stuff, you will actually give them a new name, and refer them with the new name from the HTML page.

share|improve this answer

Press F12 in your browser to use Developer mode, then click the "network" option or tab. You'll see which requests are sent to the web server and which are retrieved from Cache.

Google's PageSpeed Insights can also help.

share|improve this answer

Your Answer

 
discard

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.