Browser Back Button and Data Caching

By default, the web browser will always cache the data and when a user clicks on the browser Back button, the previously cached data will be loaded instead of generating a fresh request. While this is acceptable in most of the cases, some applications may not want this functionality. For example, a one-time form that has already been submitted etc.

All that is required is a set of instructions for the web browser. I have presented here three ways and any approach will be enough.


<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate, post-check=0, pre-check=0" />
<meta http-equiv="Pragma" content="no-cache" />


header("Cache-Control: no-cache, no-store, must-revalidate, post-check=0, pre-check=0");
header("Pragma: no-cache");


$this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
$this->output->set_header("Pragma: no-cache"); 

This will prevent your browser from caching the page.


Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s