Cache!!! How to Make sure that visitor gets the latest page

admin

Administrator
Staff member
How to make sure that visitors are getting the actual page not the cached one. <br />
<br />
I change some graphics on my page but visitors dont get it unless refreshed.<br />
<br />
How to avoid it and how to make sure that they will get every change without the need of refresh.<br />
<br />
:confused:<!--content-->Use this meta tag.It will make sure that the page is not cached in the users browser.<br />
<br />
<META HTTP-EQUIV="Pragma" CONTENT="no-cache"><!--content-->You start with META tags in the HEAD of the page. <br />
Not well supported by some browsers.<br />
<br />
The first instructs no caching:<br />
<meta HTTP-EQUIV="Pragma" CONTENT="no-cache"><br />
<br />
The second is necessary because IE5 ignores the pragma:<br />
<br />
<META HTTP-EQUIV="Expires" CONTENT="-1"><br />
That expires the page as soon as it is born.<br />
<br />
However that may still not work in IE because it it is in the head where<br />
it has to be. In some kind of twisted logic IE sees the META tags, but <br />
because the page has not yet been loaded there is nothing to cache so it <br />
ignores it. Then when the page is loaded, it caches it. The solution <br />
from Micro$oft is to duplicate the tags after the end of the body. <br />
However they have to be in the head so you end up with this silly looking, <br />
but effective page setup:<br />
<br />
<HTML><br />
<HEAD><br />
<TITLE>---</TITLE><br />
<META HTTP-EQUIV="Pragma" CONTENT="no-cache"><br />
<META HTTP-EQUIV="Expires" CONTENT="-1"><br />
<br />
all the other head stuff<br />
<br />
</HEAD><br />
<BODY><br />
<br />
All the good stuff that makes the page worthwhile<br />
<br />
</BODY><br />
<HEAD><br />
<META HTTP-EQUIV="Pragma" CONTENT="no-cache"><br />
<META HTTP-EQUIV="Expires" CONTENT="-1"><br />
</HEAD><br />
</HTML><br />
<br />
<br />
<br />
For ASP if you want the same non-cache effect, here's the header <br />
information: <br />
<% Response.CacheControl = "no-cache" %>><br />
<% Response.AddHeader "Pragma", "no-cache" %> <br />
<% Response.Expires = -1 %><br />
<br />
I don't know if once does it for ASP or if you have to repeat <br />
that as well. <br />
<br />
<br />
And of course Netscrap always has to add a twist of its own. Pages <br />
with forms in Netscrap can be a problem especially for secure environments.<br />
<br />
Netscape suggests the following JavaScript be used in the BODY tag <br />
of all pages that should not be cached: <br />
<body onLoad="if ('Navigator' == navigator.appName) document.forms[0].reset();"> <br />
<br />
With all of that there is still a small chance that there is still an <br />
unreported bug or a fringe browser that will screw up but this should <br />
be 99% effective.<br />
<br />
<br />
Of course preventing caching of the pages is still no guarantee that all images will be reloaded, and used from cache, but most of the time the images should not get cached if the pages are not cached, just make sure that none of the images are not on other pages that are being cached.<br />
<br />
Cd&<!--content-->Great to see detailed help, thanks. <br />
<br />
I checked the source-code of many good sites and surprised to see that most of them are not using such codes but still we get the latest page, or may be we think only that we are getting the latest one.<br />
<br />
I think there should be some other technique too, coz if we stop page caching at all, this will re-load the whole page everytime from scratch and will give the impression that the site is slow. (Am i getting it correctly?)<br />
<br />
Please advise<!--content-->i think most(sain) peeps empty their TIF and cookies...:D ;) :P<!--content-->Many sites do not need to wory about caching because they are using static page that don ot require constant refreshing or they are using dynamic pages generated by asp, jsp, php, etc, and the link come across with arguments that force a reload, becasue there is a query present.<br />
<br />
As for non-cached page loading slow. They obviously lake longer, but if a site is slow loading it is because of bad design. Load a pge with trash graphics and Geewhiz stuff, and it will load slow. <br />
<br />
The top-sites load quickly because they do not trash up their pages.<!--content-->Found good information on this caching issue on <!-- m --><a class="postlink" href="http://www.web-caching.com">http://www.web-caching.com</a><!-- m -->. />
<br />
An excellent introduction to caching concepts, with links to other online resources. <br />
<br />
<br />
:cool:<!--content-->
 
Back
Top