WordPress.org

Ready to get started?Download WordPress

Forums

Prevent Browsers Caching (1 post)

  1. WPers
    Member
    Posted 6 years ago #

    Hi everybody,

    I'd like to find something that will give viewers an updated page whenever they enter a page. It will be used for current conditions and I want to avoid any caching their browser/server will do. I have found a couple, and try adding:

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

    to my meta tags (header.php), but they won't serve my purpose. I've tried Javascript below too:

    <script type="text/javascript">
    var domain = "mydomain.com"
    var str=location.href
    var pos=str.indexOf(domain)
    if (pos>=12 || pos=-1)
    {
    document.location.replace("http://www."+domain);
    }
    </script>

    but javascript above doesn't work properly. And i try again using this:

    <?php
    header( "Expires: Mon, 20 Dec 1998 01:00:00 GMT" );
    header( "Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT" );
    header( "Cache-Control: no-cache, must-revalidate" );
    header( "Pragma: no-cache" );
    ?>

    but still doesn't work. Possibility, these codes above is no good for this sort of thing as it's client-side. So perhaps anybody knows a good server-side script to do this (a php version), include how to use it, please let me know.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.