How to clear cache on each php page when it loads in the browser?

15,658

Solution 1

header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
//header("Content-Type: application/xml; charset=utf-8");

for clearing browser cache

Solution 2

Using php you can put this code to your head section of website:

header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', FALSE);
header('Pragma: no-cache');

Solution 3

Try this meta tag

<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE" />

Thanks

Solution 4

Set the expires header to a past date. It will only be relevant for "clearing the cache" of a particular page..... if the browser wants to. Theres little serverside code can force on the client when it comes to this sort of stuff. It can basically only make recommendations.

Solution 5

Unfortunately you cannot clear the whole browser cache using php :(

Share:
15,658
manishjangir
Author by

manishjangir

Updated on June 04, 2022

Comments

  • manishjangir
    manishjangir almost 2 years

    I want to clear browser cache in each page when it loads in the browser. I used clearcache() php function but it did not work for me. please help.

    Thanks.