• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Erin Li
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 650
 
Erin Li
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65124
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Pat Farrell
Rancher
Posts: 4678
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65124
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the term that best describes browsers is capricious.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic