Prevent Safari from caching using header()

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Werschinger

    Prevent Safari from caching using header()

    Hello PHP group

    I'm trying to prevent Safari from caching pages (e.g. private pages),
    so it is not possible to view them when hitting the back button.

    I tried it as described on Apple's developer site:


    using

    // PHP example - include at the top of your pages
    <? php
    header("Expires : Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); //
    always modified
    header("Cache-Control: no-store, no-cache, must-revalidate, max-
    age=0"); // HTTP/1.1
    header("Cache-Control: post-check=0, pre-check=0", false);
    header("Pragma: no-cache"); // HTTP/1.0
    ?>

    However, this does not work.

    Does anyone know a reliable solution?

    Many thanks.


  • Jerry Stuckle

    #2
    Re: Prevent Safari from caching using header()

    Werschinger wrote:
    Hello PHP group
    >
    I'm trying to prevent Safari from caching pages (e.g. private pages),
    so it is not possible to view them when hitting the back button.
    >
    I tried it as described on Apple's developer site:

    >
    using
    >
    // PHP example - include at the top of your pages
    <? php
    header("Expires : Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); //
    always modified
    header("Cache-Control: no-store, no-cache, must-revalidate, max-
    age=0"); // HTTP/1.1
    header("Cache-Control: post-check=0, pre-check=0", false);
    header("Pragma: no-cache"); // HTTP/1.0
    ?>
    >
    However, this does not work.
    >
    Does anyone know a reliable solution?
    >
    Many thanks.
    >
    >
    >
    You can't guarantee a page won't be cached - you can only recommend it.
    Servers along the path as well as the browser can still cache the
    information.

    Try alt.html (hint - although you are using the header() function, the
    problem is the headers themselves, not php).

    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    • Lars Eighner

      #3
      Re: Prevent Safari from caching using header()

      In our last episode,
      <43afb581-095c-481e-b360-c4ce3ab9205d@v5 7g2000hse.googl egroups.com>,
      the lovely and talented Werschinger
      broadcast on comp.lang.php:
      Hello PHP group
      I'm trying to prevent Safari from caching pages (e.g. private pages),
      so it is not possible to view them when hitting the back button.
      You cannot force this in HTML, and so you cannot force it in php,
      because php is (or should be) HTML when it reaches the browser.
      Depending upon what you mean by 'private pages,' this would seem to be a
      browser question. In some browsers you must reduce memory and disc cache to
      0 --- others have a more convenient check box for 'never use cached pages.'
      Most modern browsers are fairly good about this; some older ones would
      load new html but not reload linked css, which was a headache in
      development. Consult your browser documentation or an appropriate browser
      group.

      --
      Lars Eighner <http://larseighner.com/usenet@larseigh ner.com
      God is REAL, unless explicitly declared INTEGER.

      Comment

      • Werschinger

        #4
        Re: Prevent Safari from caching using header()

        Thanks for everybody's input.

        I understand I cannot force it, but I've seen it work on other sites,
        e.g. banking sites.

        "Private" pages would be any pages you don't want others to see, like
        your email inbox for instance.

        I'm just looking for a solution for Safari in case of public or shared
        computer usage. For IE6, 7 and Firefox, the mentioned solution works.

        I've posted it in alt.html as suggested by Jerry. Maybe I should post
        in a Safari group as well.

        Comment

        • larry@portcommodore.com

          #5
          Re: Prevent Safari from caching using header()

          On Aug 13, 9:54 am, Werschinger <dinko.ve...@go oglemail.comwro te:
          Thanks for everybody's input.
          >
          I understand I cannot force it, but I've seen it work on other sites,
          e.g. banking sites.
          >
          There's the best place to start, look at the page source of those
          pages and see if you see anything obviously different.

          Comment

          • The Hajj

            #6
            Re: Prevent Safari from caching using header()

            How about forcing a session, then destroying it when they are done or
            after a certain time limit.

            Comment

            • Michael Fesser

              #7
              Re: Prevent Safari from caching using header()

              ..oO(larry@port commodore.com)
              >On Aug 13, 9:54 am, Werschinger <dinko.ve...@go oglemail.comwro te:
              >Thanks for everybody's input.
              >>
              >I understand I cannot force it, but I've seen it work on other sites,
              >e.g. banking sites.
              >>
              >
              >There's the best place to start, look at the page source of those
              >pages and see if you see anything obviously different.
              The HTTP response headers might be a better place to start.

              Micha

              Comment

              Working...