Wednesday, February 8, 2012

Prevent Browser cache PHP

Working with PHP in some times we need to avoid browser cache, Browser cache will cases you to prevent page updates when ever we work on Self Data POST in PHP,

Here I give the solution to prevent the Browser cache when reloading current page. and re-download the actual page with dynamic content.
header( "Last-Modified: " . gmdate( "D, j M Y H:i:s" ) . " GMT" );
header( "Expires: " . gmdate( "D, j M Y H:i:s", time() ) . " GMT" );
header( "Cache-Control: no-store, no-cache, must-revalidate" ); // HTTP/1.1
header( "Cache-Control: post-check=0, pre-check=0", FALSE );
header( "Pragma: no-cache" ); // HTTP/1.0

No comments:

Post a Comment