Forums Register Login

How to control cached pages?

+Pie Number of slices to send: Send
Hi all,
My problem is,I want to know how to stop users from seeing previous pages by using the back button. Like if someone fills out form fields and then submits and leaves the PC and then another user comes along and hits the back button then they can see all the past users sensitive info in the form fields.
It seems the browser is retrieving the cached pages.How can I stop this from happening. I'd like to have it that if a person tried to hit the back button then they are taken to a warning page telling them that they can't view this page and give them a link to the start page.
I've tried various methods to solve this problem but none seem to work properly.
Could anyone tell me how to tell a jsp not to use the cached pages?
thanks
Rui
+Pie Number of slices to send: Send
I use the pragma no-cache meta tag. It seems to work fine. From memory, I think the tag goes something like:
<html>
<head>
<meta param="pragma" value="no-cache">

I think
+Pie Number of slices to send: Send
Why would you use the meta tag if you can set the response headers directly?
response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Expires", "0");
- Peter
+Pie Number of slices to send: Send
<%
response.addHeader("Pragma", "NoCache");
response.addHeader("Cache-Control", "no-cache");
response.addDateHeader("Expires", 1);
%>
The official way is above......
be sure to warn users of the warning message they will get from their browsers....
+Pie Number of slices to send: Send
Hi,
I tried that and it still isn't working.
I must be doing something wrong.
Where exactly should I put the code you gave?
Should it be in the page I want not to be cached?
So when the user presses the back button this page doesn't appear?
thanks
Rui

Originally posted by Mark Simms:
<%
response.addHeader("Pragma", "NoCache");
response.addHeader("Cache-Control", "no-cache");
response.addDateHeader("Expires", 1);
%>
The official way is above......
be sure to warn users of the warning message they will get from their browsers....


And will you succeed? Yes you will indeed! (98 and 3/4 % guaranteed) - Seuss. tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 848 times.
Similar Threads
Caching is not working
restricting users resubmiting requests
Login Page Problem????
disable "back" tab in the browser?
doPost in servlets
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 19, 2024 02:47:04.