Skip to main content
Participating Frequently
June 8, 2011
Answered

IE caching on browser back

  • June 8, 2011
  • 4 replies
  • 7503 views

Hi All,

I have a form page, an action page and a confirmation page.

I submit the form page...takes me to the action page where I validate the fields...the fields are NOT valid..I place the data & the error message in session and redirect(cflocation) to the form page. In the form page I store the session variables(err message and bad data) in local variables, destroy the session variables and use the local variables thereafter.

Now I correct the values and submit the form again...goes to action page...validates and then redirect to the confirmation page.

Now if I use my browser back from the confirmation page, it takes me to the form page with the validation error message and bad data...I understand that the IE 7 browser is using the cache to get the data..but I tried using cfheader and META tags to avoid pulling from cache...still the browser pulls from cache...this doesnt happen in Firefox. I am using the following code.

<cfheader name="cache-control" value="no-cache, no-store, must-revalidate">
<cfheader name="pragma" value="no-cache">
<cfheader name="expires" value="#getHttpTimeString(now())#">

<META HTTP-EQUIV="expires" CONTENT="-1">
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<META HTTP-EQUIV="cache-control" CONTENT="no-cache, no-store, must-revalidate">

Any thoughts on how this can be resolved?

    This topic has been closed for replies.
    Correct answer BKBK

    Thank you so much for your response BKBK! I was pulled into a different prj...my apologies for the delay in responding.

    According to requirements, I cant restrict the users from going back. I think I might end up in using the javascript method I mentioned in the previous thread.

    Thank you so much for your help and time!

    Thanks,

    Madhu


    Hi Madhu,

    I'm back. I have revisited the thread and my test code. The first code that worked for me is, in fact, not much different from the one I gave above. Just the headers, no meta tags. And my headers are more or less the same as those in your original post, too!  So why does it work for me, and not for you?

    The crucial point to note is that, if IE's back and forward buttons display cached pages, then it can only be that those pages were already stored as history. This means that, in your case, IE must have disobeyed the no-cache directive. How?

    My first guess is: the web server. If you are using ColdFusion's in-built JRun Web Server, for example, then that could be the clue. This web server uses the protocol HTTP/1.0 to respond. Current browsers expect version HTTP/1.1. For example, the Cache-Control header was introduced in HTTP/1.1. It could be that HTTP/1.0 is too old for IE and, possibly, that IE isn't backward compatible as far as the HTTP protocol is concerned. The test for us to do next is therefore to compare how the headers behave for HTTP/1.0 and HTTP/1.1 web servers.

    4 replies

    Inspiring
    June 16, 2011

    Can you post a minimalist reproduction case that demonstrates what you're seeing (the least code possible which still demonstrates the issue unambiguously, and without any need for us to infer anything).  As well as an explicit description of what your expectations are and how they're not being met.

    I want to run this code and see what happens.

    --

    Adam

    BKBK
    Community Expert
    Community Expert
    June 16, 2011

    Adam Cameron. wrote:

    > I want to run this code and see what happens.

    I suspect it's a browser quirk. More specifically, of IE7.

    Inspiring
    June 16, 2011

    That doesn't mean that having a repro case to run (on IE7) isn't going to be helpful in fixing the problem.

    If I've got the code, I can work out what's wrong and go "do this", rather than this perpetual "how about this... or this... or this...?" which is a waste of everyone's time.  Equally, we don't know the OP is implementing the code correctly without seeing it.

    --

    Adam

    BKBK
    Community Expert
    Community Expert
    June 15, 2011

    Another suggestion: leave out the expires header.

    BKBK
    Community Expert
    Community Expert
    June 15, 2011

    Madhumathy1981 wrote:

    I am using the following code.

    <cfheader name="cache-control" value="no-cache, no-store, must-revalidate">
    <cfheader name="pragma" value="no-cache">
    <cfheader name="expires" value="#getHttpTimeString(now())#">

    Funnily enough, you didn't say on which page!
    Just for testing purposes, go all the way and use it on the form page, action page and confirmation page. If it works, then we will start the process of elimination.

    Participating Frequently
    June 15, 2011

    Thank you BKBK!

    I am using the META tag in all the page (form, action and confirmation page).

    I tried removing the "expires" header ...but the browser is still caching...

    Thank you for your time!

    Participating Frequently
    June 15, 2011

    I thought, may be the browser is not recognizing the header, so tried using the following code in the begining of my form page as well as confirmation page.

    Cache-control :

    <cfoutput>#GetHttpRequestData().headers["Cache-control"]#</cfoutput>

    got the following output:

         Cache-control : no-cache

    So the browser is recognizing the header....I have no idea what I am missing.

    BKBK
    Community Expert
    Community Expert
    June 12, 2011

    Shouldn't you use one set or the other? Also, I remember older versions of Internet Explorer needed to download a certain number of bytes before knowing whether or not to cache a page. Or something like that.  I can't remember exactly. Could that be the case here?

    Let's say you choose to use the HTML meta rather than the ColdFusion tags. That is,

    <HEAD>
    <META HTTP-EQUIV="expires" CONTENT="-1">
    <META HTTP-EQUIV="pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="cache-control" CONTENT="no-cache, no-store, must-revalidate">
    </HEAD>

    What happens when you place these at the bottom of the page?

    Participating Frequently
    June 13, 2011

    Thank you BKBK!

    I did try all combinations of the META and Coldfusion header tags ( only META, only cfheader, both META and cfheader)...but no success!

    I also placed the META tag after the BODY tag, as per microsoft recommendation,....that didnt work either..

    what is about the number of bytes.. I have no clue abt it but thank you....I will take this as a lead and google it...

    But please explain to me, even if you knew liitle abt it...

    Thank you for your time!

    Thanks!

    Inspiring
    June 15, 2011

    I did try all combinations of the META and Coldfusion header tags ( only META, only cfheader, both META and cfheader)...but no success!

    If you've got them in the header, there's no need to have the meta tag equivalents, the meta tags are for situations wherein - for whatever reason - one cannot put the information in the HTTP header (where it belongs).

    I also placed the META tag after the BODY tag, as per microsoft recommendation,....that didnt work either..

    Can you post a citation for this please?

    what is about the number of bytes.. I have no clue abt it but thank you....I will take this as a lead and google it...

    The browser will - at a minimum - read the HTTP header.  From that it will decide whether it needs to download the rest of the doc.  For example if the header says "304 Not Modified", then the browser is most likely not going to bother getting the document itself, it'll just reuse what it has.  The caching instructions work in a similar way.

    There are situations wherein if one doesn't have settings in the header but instead has them as meta tags then the meta tag must occur within the first n bytes of the file (I do not know the value of n) because after a point it's "too late" to tell the browser things.  What sort of character encoding the doc is using is an example of this.

    I don't think this is relevant to your situation though, if you're putting the caching and expiry instructions in the header anyhow.

    I dunno what's causing your problem, either, sorry.

    --

    Adam