0

For security reasons, we don't want someone's submitted info to be stored. For instance, after coming to a page via a form submit, when I refresh, it asks if I want to send that same data again (at least in Chrome).

We're attempting to create a session-ish behavior. We're not maintaining a server session - after log in, the user gets a single page returned. Since there are no other pages for the user to navigate to once logged in (no server calls at all) it seemed simpler to handle it this way. However, refreshing the page allows the data to be resubmitted, we don't want that. You can also click the back button, then the forward button, and the page is still there, or go on to other sites, and back-button back to the page.

I found <meta http-equiv="CACHE-CONTROL" content="NO-CACHE"> but it doesn't seem to be having any effect.

Javascript solutions are acceptable, as javascript is required (not by me, don't shoot the messenger) for access.

Thanks!

Randy Hall
  • 7,716
  • 16
  • 73
  • 151

1 Answers1

1

In order to insure that the page wont cache you need to place another set of 'HEAD' tags at the bottom of the document aswell.

For example:

<HTML>
<HEAD>
<TITLE>No Cache</TITLE>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
</HEAD>
<BODY>

...

</BODY>
<HEAD>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
</HEAD>
</HTML>

source

-- or --

<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />

The specified date should be a date in the past so that the browser will immediately discard the cached copy or not cache it at all.

Eric Goncalves
  • 5,253
  • 4
  • 35
  • 59
  • Tried this... it's still showing if I navigate away and back-button into the page, refresh or back out then forward back in. – Randy Hall Nov 29 '12 at 16:14
  • @RandyHall Updated, give that a shot. Before anything remember to also clear your cache before trying these solutions. – Eric Goncalves Nov 29 '12 at 16:17
  • @RandyHall I found [this](http://stackoverflow.com/questions/1341089/using-meta-tags-to-turn-off-caching-in-all-browsers) stack overflow. – Eric Goncalves Nov 29 '12 at 16:43
  • Add that to your answer and I'll accept. People who don't know to use meta tags may find this page useful for search purposes. – Randy Hall Nov 29 '12 at 16:59