• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to control cached pages?

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<%
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....
 
Rui Ferns
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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....


reply
    Bookmark Topic Watch Topic
  • New Topic