Another post said insert the expire header. This works sometimes. I have
seen it not work too..not sure why. Probably inproper use. However, I know
one thing we use and someone else told me about a long time ago. Its a bit
tedious, but for EVERY link on EVERY page, simply append a random number. I
do this via a "utility" bean I use on every page, to help build list boxes,
drop-downs, etc. I have a routine:

public String getRandomNumber()
{
  return String.valueOf( (Math.Radnom() * 10000) );
}

I am doing this from my head..so I can't remember if this is the exact
routine. At any rate, by doing this to every link, you'll force the browser
to go to the server:

<a href="/path/page.jsp?rnd=<%= HtmlBean.getRandomNumber() %>">link</a>

The link ends up something like:

/path/page.jsp?rnd=1939383920

You can also use hex numbers/letters, or whatever you want.

The reason this works is simple. The browser stores the entire URL as its
method of looking up a cached page. Since every time a page comes back from
the server it will have a completely different set of random numbers for
each link, it will never find the page in its cache. I would use this in
conjunction with the META header or what ever else.

The one thing to note however in using the META tag. When the user hits the
BACK button in MSIE5 or later, or in NS 4.5 or later (the version we tested
anyways..not sure about any other browsers and versions), because you have
the META tage, and generall send forms and what not as Posts, the browser
will display a message of REFRESH PAGE or Page no longer in cache or
something when the back button is hit. This is an undesirable effect..looks
unprofessional.

I have seen some sites that somehow can get the back button to stay on the
same page, or go to a different page. I am not sure how they do this..and
would love to find out myself.

HTH


> -----Original Message-----
> From: A mailing list about Java Server Pages specification and reference
> [mailto:[EMAIL PROTECTED]]On Behalf Of Ravi Kodwani
> Sent: Monday, June 18, 2001 2:45 AM
> To: [EMAIL PROTECTED]
> Subject: How to avoid browser use its cache copy.
>
>
> Hi All,
> Can some body please help me? I want to write a servlet and its required
> that browser should always send request to server
> and not use cached copy.
> How to do that?
> Ravi
>
> ==================================================================
> =========
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set
> JSP-INTEREST DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to