PHP: Clear browser cache
Hi there,
this month, a small, simple, yet very useful function: A function to clear the user's browser cache!
So here goes the code:
Usage (simply call the function):
This works for most browsers (IE 5+, FF 1+, Safari 3+, Opera 8+, Chrome 1+, and many more untested should work).
You should use this function before any output (this includes blank lines) !!
Use it wisely
this month, a small, simple, yet very useful function: A function to clear the user's browser cache!
So here goes the code:
- Code: Select all
<?php
function clearBrowserCache() {
header("Pragma: no-cache");
header("Cache: no-cache");
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
}
?>
Usage (simply call the function):
- Code: Select all
<?php
clearBrowserCache();
?>
This works for most browsers (IE 5+, FF 1+, Safari 3+, Opera 8+, Chrome 1+, and many more untested should work).
You should use this function before any output (this includes blank lines) !!
Use it wisely