Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Whenever I update my website by uploading a new index.html or index.php, it always takes a long time (e.g. hours or days) for that change to propagate to my browser.

Even when I hit F5, I still get the old page loaded (quite fast too), so I'm guessing that it's being cached somewhere.

The problem happens in Firefox and Chrome.

Currently I get around this by using a different access URL every time (e.g. every time I make a change, I enter my URL as http://www.example.com/?a=43784 with a different random number every time.)

What's the correct solution to this problem? (For example, I can't imagine a news website would be very useful if people's computers/browsers cached the results for hours/days)

share|improve this question
2  
Probably your browser settings. I always turn off all caching in at least a single browser on my system, just to avoid these issues. Did you try a hard refresh, CTRL+R or CTRL+F5 ? –  pritaeas Mar 3 '12 at 12:01
    
Aha, CTRL+R works. –  CaptainCodeman Mar 3 '12 at 12:06
    
But I can't tell the users to press CTRL+R, how can I make sure users are always seeing the latest version of the website? –  CaptainCodeman Mar 3 '12 at 12:07
1  
What kind of http response headers are you returning on requests to your home page? –  mahnsc Mar 3 '12 at 13:24
    
mahnsc: None that I know of. Is that what the problem is? –  CaptainCodeman Mar 3 '12 at 14:41
show 1 more comment

2 Answers

Probably your website is too optimized for speed. If your server uses Apache you can change the default config by adding an .htaccess file with the configuration that works for you.

There are many web pages on the Internet that can help you on this task, like for example: http://www.askapache.com/htaccess/speed-up-sites-with-htaccess-caching.html

Please note that some Apache servers have the .htaccess file disabled, and in that case it will not work.

share|improve this answer
add comment

Cache-Control and Expires headers can be used to indicate that specific elements need to be cached for longer or shorter periods.

Typically, you want images and other objects to have a far-future expiration for network efficiency and more dynamic content to have shorter expiration or no caching at all.

share|improve this answer
add comment

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.