Php Flow » Php

Prevent Browser cache PHP

Working in web development sometimes you need to reload the page from source not cache, this problem accrued when we are using Self Data POST in PHP. So solve this problem in php we will define header. The header tells the browser that for each request get response from server not cache.

1
2
3
4
5
6
7
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");

The only catch to setting headers is that you must do so before any of the body is generated. This means that all calls to header( ) must define at the very top of your file, even before the tag.

Did you enjoy this article? Share it!

About the Author:

Hi, This is Parvez Alam from India. I am software developer with 4 years’ experience in web development. I have submitted articles on PHP, Mysql, Magento,CSS, HTML, jQuery, web designing and social API. You can subscribe to my blog via RSS/Twitter/Google plus and Facebook.

Random Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>