I use Servlet to control the JSP flow. When user press 'Back' button at the browser, it will load the page from cache (not retrieve info from the server) i.e. the wrong (not updated) info will be shown.
I already set the JSP page as following:
<%
response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
%>
But it doesn't work for my case.
I am using tomcat 3, IE 5.5
Can anyone kindly give me suggestion how to solve it ? Thanks a lot.
Discussions
Web tier: servlets, JSP, Web frameworks: Servlet/JSP caching problem - Back button issue
-
Servlet/JSP caching problem - Back button issue (6 messages)
- Posted by: Sharon Wong
- Posted on: January 07 2002 01:37 EST
Threaded Messages (6)
- Servlet/JSP caching problem - Back button issue by joseph yi on January 07 2002 20:15 EST
- Servlet/JSP caching problem - Back button issue by Sharon Wong on January 07 2002 21:14 EST
- Servlet/JSP caching problem - Back button issue by Jessica Sant on January 08 2002 09:37 EST
- Servlet/JSP caching problem - Back button issue by Sharon Wong on January 07 2002 21:14 EST
- Servlet/JSP caching problem - Back button issue by sachin sahasrabuddhe on January 08 2002 23:08 EST
- Servlet/JSP caching problem - Back button issue by sachin sahasrabuddhe on January 08 2002 23:26 EST
- Servlet/JSP caching problem - Back button issue by Sharon Wong on January 10 2002 11:16 EST
- Servlet/JSP caching problem - Back button issue by sachin sahasrabuddhe on January 08 2002 23:26 EST
-
Servlet/JSP caching problem - Back button issue[ Go to top ]
- Posted by: joseph yi
- Posted on: January 07 2002 20:15 EST
- in response to Sharon Wong
usually when you push 'back' in the browser software, the browser (and not the server) usually displays a previously requested page and not the results of a new request. setting no-cache in the response simply guarantees that the browser regenerates the page on a new request for the page. Hitting back doesn't qualify as a new request.
Therefore, you'd have to hit back and press refresh or add a back button on your site to make it a new request.
i hope this clarifies things. -
Servlet/JSP caching problem - Back button issue[ Go to top ]
- Posted by: Sharon Wong
- Posted on: January 07 2002 21:14 EST
- in response to joseph yi
Thanks a lot to your info. I know it will work when press 'back' and press 'refresh' to update the content.
However, in some big shopping site (e.g. amazon), even you keep pressing Back button, the information in the shopping basket is the most updated one (without loading the cache version from your browser and you don't need to press 'refresh'). How can they do this ?
-
Servlet/JSP caching problem - Back button issue[ Go to top ]
- Posted by: Jessica Sant
- Posted on: January 08 2002 09:37 EST
- in response to Sharon Wong
I believe they have a small Javascript function at the beginning of their page maybe an onLoad() function? that refreshes the page. -
Servlet/JSP caching problem - Back button issue[ Go to top ]
- Posted by: sachin sahasrabuddhe
- Posted on: January 08 2002 23:08 EST
- in response to Sharon Wong
I have used this and it works perfectly for me !!
response.setHeader( "Pragma", "no-cache");
response.setHeader( "Cache-Control", "no-store, no-cache");
The no-store directive does not let the page be stored. So browser has to make a new request even on pressing a back button. -
Servlet/JSP caching problem - Back button issue[ Go to top ]
- Posted by: sachin sahasrabuddhe
- Posted on: January 08 2002 23:26 EST
- in response to sachin sahasrabuddhe
One more note,
I think Expires should be -1. 0 means it never expires !! -
Servlet/JSP caching problem - Back button issue[ Go to top ]
- Posted by: Sharon Wong
- Posted on: January 10 2002 11:16 EST
- in response to sachin sahasrabuddhe
hi sachin sahasrabuddhe,
Is the statement you mentioned all put at the beginning of a JSP ? Is it necessary to put a set on Servlet side as i use the Servlet acts as a controller and forward JSP to client. Many Thanks.