We help IT Professionals succeed at work.

Forcing a browser to clear its cache

steva
steva asked
on
After updating my site I'd like to force users to clear their cache so they load only the new site pages.  My  main page has buttons for various products and clicking one passes that product code to the payment form.  I recently changed the product numbers for some products, but because some users still had the main page cached,  they were sending the old product numbers to the payment form, which didn't recognize them.

Thanks for any ideas
Comment
Watch Question

This website will address how to clear the cache:

http://support.mozilla.com/en-US/kb/How%20to%20clear%20the%20cache

1. Clear the cache
2. On the menu bar, click on the Firefox menu and select Preferences....
3. Select the Advanced panel.
4. Click on the Network tab.
5. In the Offline Storage section, click Clear Now.
You cant delete the users caché since that caché is inside the system of every client and is not easy to access there from a website, what you can do is set a header so that the browser don't catch the website... what language are you working in ? PHP ?

PHP:
header("Cache-Control: no-cache, must-revalidate");

Open in new window


steva:

Pleaes let me know how clearing the cache worked out for you.
mandriluy:

"You cant delete the users caché since that caché is inside the system of every client and is not easy to access there from a website, what you can do is set a header so that the browser don't catch the website... what language are you working in ? PHP ?"

You lost me with this comment !

Correct me if I am misunderstanding this but..

"I recently changed the product numbers for some products, but because some users still had the main page cached,  they were sending the old product numbers to the payment form, which didn't recognize them."

This usually means that some users are able to access this website using the new product codes and some are not.  Given this fact the author is almost certainly right to assume that this is a caching issue, The above method of cleaning the cache will clean the web cache for the firefox browser.


Author

Commented:
itguy,

I'm the designer of the web site, so clearing my cache won't clear the cache of the people accessing my web site, and that's what I need.    I think mandriluy has the right idea by having my PHP code tell the browser to not cache the page through a header command.  It won't clear the caches that already have some of my pages cached but it will keep any more of my pages from going into people's cache.  I want to give his idea some more thought, though, before I respond to him.

Thanks

ok, I stand corrected. I misunderstood what you were trying to do..
Yeah, sorry if i didn't express myself correctly.. english is not my native language :D ... the clients access your website and the page gets cached.. thats because browsers default behaviour is to use the caché.. and of course you cant go to every PC of every client and modify their browsers settings :P ... so what i suggested you is to disable your clients caché for your website sending a header telling the browser.. "no browser, you are not caching this one"... are you using php ?

Author

Commented:
Yes, I'm using PHP.  And I understood what you meant the first time you said it.  It's a good idea.  I'll give you the points.

Thanks