Detecting cached file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • guischarf@gmail.com

    #1

    Detecting cached file

    I have the following code on files "a.php" and "b.php"

    -----------------------------
    FILE a.php
    -----------------------------

    <form action="a.php" method="post">
    <input type="hidden" name="active" value="1">
    <input type="submit" name="Submit" value="Send">
    </form>


    <?php
    if (isset($_POST['active']) && $_POST['active'] == 1) {
    ?>
    <script language="JavaS cript" type="text/JavaScript">
    alert('Thank you.');
    </script>
    <?php ; } ?>

    <a href="b.php">Go to b.php</a>

    --------------------------
    FILE b.php
    --------------------------

    <a href="#" onClick="histor y.back()">Back to a.php</a>

    ---------------------------


    Works like this.

    1. The user fills and sends the form in a.php
    2. a.php loads and displays a thank you message
    3. The user clicks on "Go to b.php"
    4. b.php loads and the user clics on "Back to a.php"
    5. a.php loads (I assume is loading from the cache") and displays thank
    you message again, which should not occur!!!


    I tried this on file a.php


    <?php
    if (isset($_POST['active']) && $_POST['active'] == 1) {
    ?>
    <script language="JavaS cript" type="text/JavaScript">
    if (!window.IWasHe re) {
    alert('Thank you.');
    var IWasHere = true;
    }
    </script>
    <?php ; } ?>

    But did not work. Also tried includding a pragma no-cache and expires
    tags:

    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Expires" content="-1">

    but did not work either.

    Any ideas?

    Thanks,

    Guillermo Scharffenorth

  • Randy Webb

    #2
    Re: Detecting cached file

    guischarf@gmail .com wrote:[color=blue]
    > I have the following code on files "a.php" and "b.php"[/color]

    <snip>
    [color=blue]
    >
    > <a href="#" onClick="histor y.back()">Back to a.php</a>
    >
    > ---------------------------[/color]

    <snip>
    [color=blue]
    > 1. The user fills and sends the form in a.php
    > 2. a.php loads and displays a thank you message
    > 3. The user clicks on "Go to b.php"
    > 4. b.php loads and the user clics on "Back to a.php"
    > 5. a.php loads (I assume is loading from the cache") and displays thank
    > you message again, which should not occur!!![/color]

    Change your link from history.back() to something a little simpler:

    <a href="A.php?PHP AppendedTime">B ack to a.php</a>

    And when b.php is sent to the browser, have php append the current
    server time, in milliseconds, to the link.

    --
    Randy
    comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly

    Comment

    • Danny

      #3
      Re: Detecting cached file


      Use PHP header() to have the browser no cache the pages, which is cheesy
      IMO as you can just instead, use a target="thankyo u.html" on the form.


      Danny

      On Sat, 25 Jun 2005 09:52:23 -0700, <guischarf@gmai l.com> wrote:
      [color=blue]
      > I have the following code on files "a.php" and "b.php"
      >
      > -----------------------------
      > FILE a.php
      > -----------------------------
      >
      > <form action="a.php" method="post">
      > <input type="hidden" name="active" value="1">
      > <input type="submit" name="Submit" value="Send">
      > </form>
      >
      >
      > <?php
      > if (isset($_POST['active']) && $_POST['active'] == 1) {
      > ?>
      > <script language="JavaS cript" type="text/JavaScript">
      > alert('Thank you.');
      > </script>
      > <?php ; } ?>
      >
      > <a href="b.php">Go to b.php</a>
      >
      > --------------------------
      > FILE b.php
      > --------------------------
      >
      > <a href="#" onClick="histor y.back()">Back to a.php</a>
      >
      > ---------------------------
      >
      >
      > Works like this.
      >
      > 1. The user fills and sends the form in a.php
      > 2. a.php loads and displays a thank you message
      > 3. The user clicks on "Go to b.php"
      > 4. b.php loads and the user clics on "Back to a.php"
      > 5. a.php loads (I assume is loading from the cache") and displays thank
      > you message again, which should not occur!!!
      >
      >
      > I tried this on file a.php
      >
      >
      > <?php
      > if (isset($_POST['active']) && $_POST['active'] == 1) {
      > ?>
      > <script language="JavaS cript" type="text/JavaScript">
      > if (!window.IWasHe re) {
      > alert('Thank you.');
      > var IWasHere = true;
      > }
      > </script>
      > <?php ; } ?>
      >
      > But did not work. Also tried includding a pragma no-cache and expires
      > tags:
      >
      > <meta http-equiv="Pragma" content="no-cache">
      > <meta http-equiv="Expires" content="-1">
      >
      > but did not work either.
      >
      > Any ideas?
      >
      > Thanks,
      >
      > Guillermo Scharffenorth
      >[/color]



      --
      Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

      Comment

      • Randy Webb

        #4
        Re: Detecting cached file

        Danny wrote:[color=blue]
        >
        > Use PHP header() to have the browser no cache the pages,[/color]

        And if the browser/UA/proxy/etc doesn't honor it? You are right back
        where you started. Read my reply, it might enlighten you.
        [color=blue]
        > which is cheesy IMO as you can just instead, use a
        > target="thankyo u.html" on the form.[/color]

        Yes, if that is the intent. But it depends on what the intent of a.php
        and b.php use is.

        Reading this group's FAQ (via sig below) will do wonders for you.

        --
        Randy
        comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
        Answer:It destroys the order of the conversation
        Question: Why?
        Answer: Top-Posting.
        Question: Whats the most annoying thing on Usenet?

        Comment

        • guischarf

          #5
          Re: Detecting cached file

          I must use history back because I want the user to come back not just
          to the previous file (a.php), but also to the specific place in the
          previous file where the user clicked in order to go to b.php. Besides,
          theres is no only b.php, there could be b.php, c.php, ... etc.

          Thanks.

          GS

          Comment

          • guischarf

            #6
            Re: Detecting cached file

            > Change your link from history.back() to something a little simpler:[color=blue]
            > <a href="A.php?PHP AppendedTime">B ­ack to a.php</a>[/color]

            I must use history back because I want the user to come back not just
            to the previous file (a.php), but also to the specific place in the
            previous file where the user clicked in order to go to b.php. Besides,
            theres is no only b.php, there could be b.php, c.php, ... etc.

            I wonder if there is a way, using javacript, to detect the name of the
            file (or title of the window) from which I am coming. For example:

            1 I am in a.php and click a link that opens b.php
            2 from b.php I click history.back()
            3 back in a.php, using JS, I detect that the previous displayed window
            was b.php (or the title of the window)

            Thanks.

            GS

            Comment

            Working...