Archive for April 12th, 2007|Daily archive page

Web page caching

It happened to an application I released (PHP and CakePHP) that once got into production environments, there were some caching problems. For example after a login, the menu didn’t get the correct profile and with a simple refresh (CTRL+R) of the browser everything is solved.

Well in order to solve this problem I added to whole pages (app/views/layouts/default.thtml for the framework) the following code

<?php
header("Cache-control: no-cache");
header("Expires: " . gmdate("D, d M Y H:i:s") . " GMT");
?>
...
<meta http-equiv="pragma" content="no-cache" />
...