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 4 of 4
  1. #1
    New Coder
    Join Date
    Jan 2011
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Page caching challenge

    Hi All,

    The following code i was told does not cache, it works fine sometimes and sometimes does not (caches). I do not want the page to cache.

    PHP Code:
    header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
    header("Last-Modified: " gmdate("D, d M Y H:i:s" ) . " GMT");
    header("Cache-Control: no-store, no-cache, must-revalidate");
    header("Cache-Control: post-check=0, pre-check=0"false );
    header("Pragma: no-cache"); 
    What might be the possible cause and fix to it? Your help is much appreciated.

    Regards.

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,537
    Thanks
    8
    Thanked 1,093 Times in 1,084 Posts
    Is there a particular thing on a page that should not cache, or the entire page?
    I'm sort of thinking that maybe PHP SESSION might be something you could utilize.

  • #3
    Regular Coder
    Join Date
    Jun 2010
    Posts
    301
    Thanks
    68
    Thanked 8 Times in 8 Posts
    There's nothing you can do to stop a browser caching a page - if the browser wants to cache a page, it will, and it's beyond your control, because you have no idea who is going to use what on the client-side to view your web page.

    You should aim to write code that works whether or not the page is cached.

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,537
    Thanks
    8
    Thanked 1,093 Times in 1,084 Posts
    XmisterIS ... you are correct, but what a PHP outputs to the browser "on the fly"
    can be controlled. Sure, someone can take a snapshot of a page at any given time,
    but when they or anyone else returns to it, the page will be changed no matter how
    much caching they do. The web page they are viewing is not "static". It's rendered
    on the fly.


  •  

    Posting Permissions

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