Prevent page caching in php using header() function

Last updated 5 years, 8 months ago | 1307 views 75     5

Tags:- PHP

PHP | header() function

By sending the headers bellow, we change the browser’s default cache settings. We can override any of those settings and force the browser to not cache. In this code we just have to set date in the past.

// Date in the past
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache");
header("Pragma: no-cache");