3/22/2001 1:20:38 AM, "Rob L'Estrange" <[EMAIL PROTECTED]> wrote:

>Thanks Kare.
>
>I've taken a look at the HTTP/1.1 RFC. I have a couple of questions about
>the following code,
>> > >   response.addHeader("Pragma", "No-cache");
>> > >   response.addHeader("Cache-control", "no-cache");
>> > >   response.addDateHeader("Expires", 1);
>
>Fistly, I recognize that this code will prevent a cache and I recognize that
>this is a published way of preventing caching from within JSP's (see
>O'Reilly's "Java Server Page" page 264 for instance). But after reading the
>RFC, I have two questions about this code:
>1. Wouldn't the use of response.addDateHeader() alone be enough to control
>caching (and non-caching)? That is, if response.addDateHeader() is used,
>wouldn't the calls to response.addHeader() be unnecessary?

I think the reason for using multiple headers is a shotgun approach to sending 
something that the browser will understand and respond to. In other words, browser A 
understands the no-cache pragma but not the
cache-control header, while browser B understands neither and needs to have the 
Expires header set to explicitly age it out.


>2. I'm wondering why a figure of 1 is used in
>response.addDateHeader("Expires",1)? I thought a value of 0 or less would be
>more appropriate, like, addDateHeader("Expires",0)?

Whatever, the difference is one millisecond, either  1 Jan 1970 00:00:00.0000 or 1 Jan 
1970 00:00:00.0001. The value is not an offset from current time, it's milliseconds 
since the epoch.

I use this for standard cache-defeating:
  response.setDateHeader("Expires", 0);
  response.setHeader("Pragma", "no-cache");
  if (request.getProtocol().equals("HTTP/1.1"))
  {
      response.setHeader("Cache-Control", "no-cache");
  }


Jeff Sahol
[EMAIL PROTECTED]

===========================================================================
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