How we can prevent Web browsers caching?

June 15, 2010 | Filed Under PHP | Comments Off
Using HTML meta tags: we can prevent Web browsers caching.
<meta content="Sun, 20 Fed 2000 01:11:11 GMT"
/>
<meta http-equiv="Pragma" content="no-cache" />
Here  free trial offer Meta tag tells the browser, cached copy of the page in back date.That means   browser should never cache the page.
But some browser does not support this approach .If you are working with php and include the header that has Meta definition.
For this case, use php Header function to produce the two meta tags above
<?php
header('Expires: Sun, 20 Fed 2000 01:11:11 GMT');
header('Pragma: no-cache');
?>
Or use
<?php
header('Expires: Sun, 20 Fed 2000 01:11:11 GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', FALSE);
header('Pragma: no-cache');
?>

In this case visitor will always see the latest contents.

Comments

Comments are closed.

© PHPInterviewQuestion.com 2009 - 2012

eXTReMe Tracker