O'Reilly logo

CakePHP 2 Application Cookbook by Jorge González, James Watts

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Cache control

Manipulating the HTTP cache is a great way to control the impact of visitors and users on your application's resources. CakePHP provides a range of options to control both expiration and validation, and manage how clients and proxies engage with your content.

In this recipe, we'll look at the various ways you can handle the HTTP cache to your advantage.

Getting ready

In this recipe, we'll use a simple controller to show each of the caching options available. So, create a file named CacheController.php in app/Controller/, with the following content:

<?php
App::uses('AppController', 'Controller');

class CacheController extends AppController {

  public $autoRender = false;
}

How to do it...

Perform the following steps:

  1. Add a cached() method ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required