How to prevent page caching

  • Profile Image
    lucas
    Asked on November 07, 2013 at 04:43 PM

    This is a php code that prevents browser caching my pages, i believe.

     

    //Set no caching
    header("Expires: Mon, 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");
    ?>

     

    Do i have to upload it to my server or just paste it  somewhere in my html within my webpage for it to work?

     

     

  • Profile Image
    Mike_T
    Answered on November 07, 2013 at 05:22 PM

    If you use .php driven site, then you can use that code at the top of the .php file. In case you use simple HTML, you can try the following technique:

    Using tags to turn off caching in all browsers?

    However, please note that the question is not related to our form builder. The http://stackoverflow.com/ might be a better place for generic web related questions.

    Please feel free to contact us if you need any further assistance.