Forum Moderators: phranque

Message Too Old, No Replies

Stopping The Cache on the Browser

         

Fortune Hunter

3:39 pm on Jul 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I designed a site for someone that reguarly posts new content on the home page such as press releases, new photos, etc. My problem is that a large part of the audience is not really web savvy and when their browser caches the site from their last visit they don't see the changes I post for them and many of them are not aware that clicking the refresh button will let them see the changes. In fact, many of them don't even know the changes were done in the first place so they don't even know to click refresh. Besides I really don't want the users having to do this anyway.

I had heard their was some type of Meta tag available that would tell the browser to always download a fresh copy of the page, but someone said browsers ignored this tag.

In short, is there any code, meta tag, etc. that I can place on a normal HTML page so that the browser will always dowload a current copy instead of displaying the cache copy?

Fortune Hunter

Little_G

10:39 pm on Jul 12, 2006 (gmt 0)

10+ Year Member



Hi,

As far as I know if you use a standard meta refresh you shouldn't have any problems with caching with any decent browser.

standard meta refresh:

<meta http-equiv="refresh" content="600">

Andrew

[edited by: rogerd at 2:40 am (utc) on July 13, 2006]
[edit reason]
[1][edit reason] No links/URLs, please. [/edit]
[/edit][/1]

Fortune Hunter

3:19 am on Jul 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Andrew:

Thanks, I will try this. However a question, why do you have the number "600" after the word content? What does that mean or what does it do? Just curious.

Fortune Hunter

physics

4:16 am on Jul 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The refresh tag is really intended to tell the browser to reload the page after N seconds, in this case 600.
What you should really do is send a no-cache header.
For example, in PHP

header("Cache-control: no-cache");
header("Expires: " .gmdate("D, d M Y H:i:s")." GMT");

kaled

9:33 am on Jul 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Never tried it, but would this work?

<meta http-equiv="cache-control" content="no-cache">

However, whilst this might work for the page itself, it would have no effect on linked files such as images or iframes. Iframes could use their own meta tags but images would require http headers to be used (I think).

Kaled.

mattur

9:53 am on Jul 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



See How (and how not) to Control Caches [mnot.net]

Meta tags are easy to use, but aren’t very effective. That’s because they’re only honored by a few browser caches (which actually read the HTML), not proxy caches (which almost never read the HTML in the document).

Also check out the Cacheability Engine [mnot.net] linked from the same site:

To help you understand how Web Caches will treat a Web page, the Cacheability Engine will look at a URL (and optionally any images or objects associated with it), giving both specific cache-related data about it, and a general commentary on how cacheable the object is.

Fantastic resource, highly recommended :)