Sajag,
I am assuming that you are developing your site as a JSP/serlvet site, and
not an HTML site. If that is the case, then yes, using the
response.setHeader() methods is a more effective way of controlling the
browser caching than using the HTML META tag equivalents. Using the
response.setHeader() method is the recommended method because:
1. Some browsers do not treat the <META> tags in the same way as the
equivalent HTTP header settings.
2. On some browsers, the <META> tag equivalents do not work when the
callPage() method is used to load a JSP file that contains the <META> tags.
I do recall that IE 5.0 sometimes still had caching problems even if you
used the list of response.setHeader() methods I listed in my previous email.
To work around that, some developers append a random number to the end of
their servlet/jsp URL, but so far, we have not found a need to do this.
Another idea I have seen is to create Java Object called "now" with a
getTime method that returns the server time. You can use the following then
to make sure that your cache is not used.
response.setDateHeader("Last-Modified", now.getTime() );
response.setDateHeader("Expires", now.getTime());
Hope this information helps!!
Celeste
-----Original Message-----
From: Sajag Patel [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 10, 2002 12:56 PM
To: [EMAIL PROTECTED]
Subject: Re: Writing scripts to the browser
Celeste,
I am currently doing something similar to that through html code, but it
still doesn't seem to work. Do you think the jsp code will work better?
Here's the html script I have:
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="Tue, 01 Jan 1980 1:00:00 GMT">
<META HTTP-EQUIV="Pragma-directive" content="no-cache">
<META HTTP-EQUIV="cache-directive" content="no-cache">
<META HTTP-EQUIV="Cache-Control:private" CONTENT="no-cache, max-age=0,
must-revalidate, no-store">
Sajag
-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Haseltine, Celeste
Sent: Wednesday, July 10, 2002 1:54 PM
To: [EMAIL PROTECTED]
Subject: Re: Writing scripts to the browser
Sajag,
You don't want to approach this problem from the user's side (browser), you
want to control it from the server side (i.e. you as the programmer).
The following headers have worked for me in my JSP pages. You may want to
use all of them, or just some of them, depending on your requirements.
response.setHeader("Cache-Control", "no-cache");//HTTP 1.0 refetch
completely next time document is
needed.
response.setHeader("Cache-Control", "must-revalidate");
response.setHeader("Cache-Control", "max-age=0");
response.setHeader("Pragma", "no-cache");//HTTP 1.1
response.setDateHeader ("Expires", 0); //prevents caching at the proxy
server, refetches ONLY if it
has been modified since last fetch
response.setHeader("Cache-Control","no-store"); //HTTP 1.1
Hope this helps!
Celeste
-----Original Message-----
From: Sajag Patel [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 10, 2002 12:34 PM
To: [EMAIL PROTECTED]
Subject: Writing scripts to the browser
Hey guys,
Does anyone know how to write script to the browser so that you can tell
the broswer to go get the file each time from the server instead of from the
cache.
For instance, if I change the option on IE, under tools, internet options,
settings, and click the Get New Version for Every visit to the page, my app
works fine, other wise it gets the cached version with older results.
So is there a way to check this everytime time and to automatically reset
it to my needs. Any feedback would be of great help. Thanks
Sajag
===========================================================================
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://archives.java.sun.com/jsp-interest.html
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.jsp
http://www.jguru.com/faq/index.jsp
http://www.jspinsider.com
===========================================================================
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://archives.java.sun.com/jsp-interest.html
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.jsp
http://www.jguru.com/faq/index.jsp
http://www.jspinsider.com
===========================================================================
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://archives.java.sun.com/jsp-interest.html
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.jsp
http://www.jguru.com/faq/index.jsp
http://www.jspinsider.com
===========================================================================
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://archives.java.sun.com/jsp-interest.html
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.jsp
http://www.jguru.com/faq/index.jsp
http://www.jspinsider.com