htmlcachingmeta-tagsmetatag

Why is cache control not working?


I set the cache control to "no-cache" and "max-age=0" still when I click on back button of the browser it shows the previous page. Actually the problem is when we login from login page and then it gets login to the main page but if we hit back button then it again shows the login page.Thats why i want to apply cache-control to no-cache but it is not working. Is there any other option to do it. What I've done is as follows I added these two meta-tag to head section of page :

<meta http-equiv="cache-control" content="max-age=0"/>
<meta http-equiv="cache-control" content="no-cache"/>

Thanks in advance.


Solution

  • I had the same problem in one of my javascript project, please pick this code if useful to resolve your issue, this is one of the way to handle browser back button

    <script type="text/javascript">
            window.history.forward();
            function noBack(){
                window.history.forward();
            }
    </script>
    
    <body onload="noBack();">