Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: No Cache

  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    Brisbane, Australia
    Posts
    181
    Thanks
    1
    Thanked 0 Times in 0 Posts

    No Cache

    How do you stop PHP from allowing the browser to keep the file as a cache. You do this in the header somehow. PHP.NET doesnt go into it. I couldn't find anything..


    header( ...? );
    -mR_eGo
    _______________________
    Programming since
    3 years old.

  • #2
    Regular Coder
    Join Date
    Feb 2003
    Posts
    345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This is what I use. I found it somewhere in php.net.
    PHP Code:
    <?php
    header
    ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
    header("Pragma: no-cache");
    header("Cache-Control: no-store, no-cache, must-revalidate");
    header("Cache-Control: post-check=0, pre-check=0"false);
    ?>

  • #3
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You found it here

    http://be.php.net/header


  • #4
    Regular Coder
    Join Date
    Feb 2003
    Posts
    345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Actually the page I took it from was "php.net/header_SOMETHING" (don't remember) but it must have changed since I cannot find it anymore. In the page you're refering to, header("Cache-Control: post-check=0, pre-check=0", false); is missing. Who cares! that's not a big deal. From Belgium, uh?

  • #5
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by maltrecho
    In the page you're refering to, header("Cache-Control: post-check=0, pre-check=0", false); is missing. Who cares! that's not a big deal. From Belgium, uh?
    Missing? I see it tree times there. (once in the actual manual and in 2 posts)
    PHP Code:
    <?php
    // Date in the past
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");

    // always modified
    header("Last-Modified: " gmdate("D, d M Y H:i:s") . " GMT");
     
    // HTTP/1.1
    header("Cache-Control: no-store, no-cache, must-revalidate");
    header("Cache-Control: post-check=0, pre-check=0"false);

    // HTTP/1.0
    header("Pragma: no-cache");
    ?>
    But i agree it probably doesn't make much difference. You cant safely prevent clientside caching, since some browsers can ignore caching instructions.

    Belgium, indeed. The rouring mouse !


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •