Disable all browser page caching in Laravel

Sometimes you don’t want to allow any content coming out of Laravel to be cached. The easiest way of doing this is a filter to send no cache headers. Add this snippet to the bottom of your filters.php file.

Route::filter('after', function($response)
{
// No caching for pages
$response->header("Pragma", "no-cache");
$response->header("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0");
});

One thought on “Disable all browser page caching in Laravel

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