wood burning stoves 2.0*
The moose likes Servlets and the fly likes request's no-cache vs response's no-cache Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "request Watch "request New topic
Author

request's no-cache vs response's no-cache

Erin Li
Greenhorn

Joined: Mar 07, 2010
Posts: 5
Hi there,
I just joined the forum. I'm learning Servlet/JSP. I stand somewhere on the intermediate level.
I googled to understand the difference between request's no-cache and response's no-cache but couldn't find some easy explanation with examples. I know response's no-cache is used whether browser client should cache the page locally or not. What is the practical use of request's no-cache header?

Thanks in advance for the responses.

Erin.
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 643
Does this help? http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9.1
Erin Li
Greenhorn

Joined: Mar 07, 2010
Posts: 5
Mark,
What I understood from rfc is:
Request Cache-Control header tells us what is the browser default cache-ability and server can override that default cache-ability via response's header.
Please let me know whether my understanding is correct.

I wrote a servlet to test cache-control header:



I am expecting the browser to get the copy of page from cache, that doesn't seem to happen as it prints the new date whenever I refresh/request for the servlet resource. Please let me know what I'm missing here.

Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61206
    
  66

You can't force the browser to cache the page. That's a matter that the browser decides based upon divergent circumstances, differing browser implementations, and user-specified settings.

All the headers do is to inform the browser of your intentions. The browsers will then do whatever they darn well please.

Trying to exert completely deterministic control over browser actions is impossible, and leads to madness and hair loss.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4657
    
    5

Bear Bibeault wrote:You can't force the browser to cache the page....Trying to exert completely deterministic control over browser actions is impossible, and leads to madness and hair loss.

And conversely, you can't force the browser to not cache the page. All you can do is give hints to the browser, which will often ignore your hints.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61206
    
  66

I think the term that best describes browsers is capricious.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: request's no-cache vs response's no-cache