Computing.Net > Forums > Web Development > Getting no cache to work

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Getting no cache to work

Reply to Message Icon

Name: sfAdmin
Date: January 8, 2008 at 10:56:47 Pacific
OS: n/a
CPU/Ram: n/a
Product: n/a
Comment:

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.



Sponsored Link
Ads by Google

Response Number 1
Name: Michael J (by mjdamato)
Date: January 8, 2008 at 13:41:57 Pacific
Reply:

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


0

Response Number 2
Name: sfAdmin
Date: January 8, 2008 at 14:43:14 Pacific
Reply:

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


0

Response Number 3
Name: Michael J (by mjdamato)
Date: January 8, 2008 at 14:50:56 Pacific
Reply:

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


0

Response Number 4
Name: sfAdmin
Date: January 8, 2008 at 15:39:21 Pacific
Reply:

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.


0

Response Number 5
Name: sfAdmin
Date: January 9, 2008 at 12:38:54 Pacific
Reply:

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.



0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Web Development Forum Home


Sponsored links

Ads by Google


Results for: Getting no cache to work

getting FXP to work for server www.computing.net/answers/webdevel/getting-fxp-to-work-for-server/225.html

javax.mail problem with cc option www.computing.net/answers/webdevel/javaxmail-problem-with-cc-option/2684.html

form validation, multiple fields www.computing.net/answers/webdevel/form-validation-multiple-fields/3608.html