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

View caching

Caching your views is an important step towards improving the loading time of your application as content is served faster. This can have a noticeable effect on users, as they get to content and features quicker, making them a bit happier.

In this recipe, we'll build an example scenario that shows off some of the base caching features of CakePHP.

Getting ready

First, open your core.php file in app/Config/, make sure the following line is not commented out, and set it to true:

Configure::write('Cache.check', true);

This configuration option enables and generates cached view files for requests.

Also, in your bootstrap.php file in app/Config/, make sure that CacheDispatcher is set in your Dispatcher.filters configuration. Take a look at the ...

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