Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Good day,
I'm using JSP 2.4 and Struts 2, and I'm having a problem getting certain pages to not be cached. I have tried the following:
request.setHeader("cache-control", "no-cache");
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="0" >
<meta http-equiv="cache-control" content="must-revalidate" />
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">None worked. I want the browser to go to the server when it hits a certain page instead of getting it from the cache. Can anyone suggest anything.
Thanks.

Have you checked your browser settings to ensure it is not set to always use the cache? The server can "request" that the browser not cache the content, but ultimately it is up to the browser.
Michael J

My application consists of a series of forms and confirmations, and once it is submitted I destroy the session and I don't want someone to be able to use the back button to see the cached form data. Is there a way to accomplish this no matter what the setting on the browser is?
Thanks

I don't think you can guard against it 100%, but there are plenty of articles on the subject. here's one: http://searchsecurity.techtarget.co...
Michael J

Thanks for the link, I tried the no-store and it works better. In Fire Fox it works if the page has no Dojo controls, and in IE it doesn't work, as the article mentions.
In my application, all the processing actions are done independently of the web pages and they redirect to "view" pages after each step so therefore there is no POST submit for any of the form pages. I notice in an earlier PHP application that no-cache worked but every page also had a POST submit through JavaScript. Perhaps only with a POST or GET submit to a page that a browser is actually forced to go to the server...
I wonder how those websites with logged in users prevent a person from seeing the previous page once the user clicks the logout button or link.

Update:
Just to add if anyone has the same problem, I found out that putting this line:
response.setHeader("Cache-Control","no-store");
before any html text in the JSP file seems to stop the caching in IE 7 and Fire Fox 2 no matter what the settings. The same should apply to other languages such as PHP.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |