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" />
...

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s