manishjangir
manishjangir

Reputation: 1695

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

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.

Upvotes: 2

Views: 20505

Answers (5)

Umair Hamid
Umair Hamid

Reputation: 3557

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');

Upvotes: 4

Saiyam Patel
Saiyam Patel

Reputation: 1161

Try this meta tag

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

Thanks

Upvotes: 2

Ghostman
Ghostman

Reputation: 6114

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

Upvotes: 5

j_mcnally
j_mcnally

Reputation: 6968

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.

Upvotes: 2

deadrunk
deadrunk

Reputation: 14155

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

Upvotes: 1

Related Questions