Response.Expires=0 have different effect on different machines, need urgent help

Discussion in 'Javascript' started by Jenny, May 13, 2004.

  1. Jenny

    Jenny Guest

    Need urgent help for an unsolved problem. In our ASP web application,
    we creat a Back button and if user click on this button, it execute
    history.go(-1) to go back to the previous page. All our users use IE
    6.0 and most of them don't have problem with this button. But one user
    reported everytime he click on this button, there is a pop-up window
    shows up and ask him refresh and reload the page, after he clicks OK,
    the previous page will be loaded with all the empty fields. So he will
    lose all his input. I searched the google, it did mention there is
    problem with Netscape for history.go(-1), but can not find any
    articles for IE. And then I realized I use Response.Expires=0 to
    disable the cache and force the browser to reload, but according to
    the discussion from Internet, it might work for some type of browser,
    might not work for other types of browsers. But we all use IE, I use
    IE 6.0, he use either IE5.5 or IE 6.0, why it won't expire cache on
    mine, but on his? The following is my code's snippet. Your help is
    HIGHLY appreciated.

    <% Response.Buffer = True %>
    <% Response.Expires = 0 %>
    <% Response.AddHeader "Pragma", "No-Cache" %>

    <script LANGUAGE="javascript">
    <!-- Back Function
    function BackUp()
    {history.go(-1);}
    -->
    </script>

    In the html code,

    <form method="post" action="NextPage.asp" id="form1" name="form1">
    /* lots of other stuff */
    <p align="center"><input type="button" Onclick="BackUp();" value="Go
    to
    Previous Page" name="Back"><input type="submit" value="Go to Next
    Page"
    name="Submit"></p>
    </form>
    Jenny, May 13, 2004
    #1
    1. Advertising

  2. Jenny

    Grant Wagner Guest

    Re: Response.Expires=0 have different effect on different machines,need urgent help

    Jenny wrote:

    > Need urgent help for an unsolved problem. In our ASP web application,
    > we creat a Back button and if user click on this button, it execute
    > history.go(-1) to go back to the previous page. All our users use IE
    > 6.0 and most of them don't have problem with this button. But one user
    > reported everytime he click on this button, there is a pop-up window
    > shows up and ask him refresh and reload the page, after he clicks OK,
    > the previous page will be loaded with all the empty fields. So he will
    > lose all his input. I searched the google, it did mention there is
    > problem with Netscape for history.go(-1), but can not find any
    > articles for IE. And then I realized I use Response.Expires=0 to
    > disable the cache and force the browser to reload, but according to
    > the discussion from Internet, it might work for some type of browser,
    > might not work for other types of browsers. But we all use IE, I use
    > IE 6.0, he use either IE5.5 or IE 6.0, why it won't expire cache on
    > mine, but on his? The following is my code's snippet. Your help is
    > HIGHLY appreciated.
    >
    > <% Response.Buffer = True %>
    > <% Response.Expires = 0 %>
    > <% Response.AddHeader "Pragma", "No-Cache" %>
    >
    > <script LANGUAGE="javascript">
    > <!-- Back Function
    > function BackUp()
    > {history.go(-1);}
    > -->
    > </script>
    >
    > In the html code,
    >
    > <form method="post" action="NextPage.asp" id="form1" name="form1">
    > /* lots of other stuff */
    > <p align="center"><input type="button" Onclick="BackUp();" value="Go
    > to
    > Previous Page" name="Back"><input type="submit" value="Go to Next
    > Page"
    > name="Submit"></p>
    > </form>


    He probably has Internet Explorer configured to always load a new copy of
    the page.

    Tools -> Internet Options -> General tab

    Click Settings... -> "Check for newer versions of stored pages:"

    His is probably set to "Every visit to the page".

    Which proves once again to handle this stuff properly, instead of
    "relying" on what browsers do, even in an Intranet environment.

    Store the form data in a server-side session of some sort, the "Go to
    Previous Page" button should then actually retrieve the ASP document
    containing the form and repopulate the form using the previously stored
    session values.

    This still doesn't handle what happens if the user clicks "Back" on their
    browser, but that can be dealt with with a redirector page between the
    form and the result pages that can identify that the user has clicked
    "Back".

    [form (set Session.r=0)] <--
    | |
    v | Session.r=1?
    [redirector] --------------|
    |
    | Session.r!=1?
    v
    [result (set Session.r=1)]

    If that makes no sense, try using a fixed width font.

    Now if the user clicks "Back" after arriving at the [result] page, the
    browser reloads [redirector], not [form]. [redirector] identifies that
    they were on [result] (because Session.r is now 1) and takes them to
    [form], repopulating the form with data stored in the server-side session
    as well. If you don't want to return to [form] when a user clicks "Back"
    on [result], that's fine, [redirector] can take ANY action, like going
    back to [result] with a message that the user shouldn't click "Back" or
    another page entirely.

    The point is, all this is handled on the SERVER, where is can be
    controlled and the behaviour is always known, and does it does not "rely"
    on some behaviour in a Web browser that can't even be trusted in an
    Intranet environment.

    --
    | Grant Wagner <>

    * Client-side Javascript and Netscape 4 DOM Reference available at:
    *
    http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/frames.html

    * Internet Explorer DOM Reference available at:
    *
    http://msdn.microsoft.com/workshop/author/dhtml/reference/dhtml_reference_entry.asp

    * Netscape 6/7 DOM Reference available at:
    * http://www.mozilla.org/docs/dom/domref/
    * Tips for upgrading JavaScript for Netscape 7 / Mozilla
    * http://www.mozilla.org/docs/web-developer/upgrade_2.html
    Grant Wagner, May 14, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Promenade

    Response.Expires and Response.Cache

    Promenade, Dec 5, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    30,746
    Promenade
    Dec 5, 2003
  2. =?Utf-8?B?Q2hyaXM=?=

    Response.Expires

    =?Utf-8?B?Q2hyaXM=?=, Jun 18, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    719
    =?Utf-8?B?Q2hyaXM=?=
    Jun 18, 2004
  3. qqq
    Replies:
    4
    Views:
    16,666
    toddbailey
    Apr 24, 2009
  4. Replies:
    8
    Views:
    625
  5. J. Muenchbourg
    Replies:
    1
    Views:
    137
    Aaron Bertrand - MVP
    Jul 8, 2003
Loading...

Share This Page