Speed up page load times by saving commonly-used web pages in Drupal’s page cache. Cached pages are faster to send to site visitors.
Table of Contents
This article is part of the Essential steps to speed up a Drupal web site article series. Other articles in this series look at improving the performance of PHP and MySQL and ways to adjust your page layout to improve web site performance.
How to enable Drupal page caching
Drupal&'s page cache is disabled by default. Enable it to speed up page load times substantially.
- Log in as your Drupal site's administrator.
- Go to the Administer » Site configuration » Performance page.
- Check the Normal checkbox for the Caching mode.
- Set the Minimum cache lifetime to 1 day.
- Click the Save configuration button
What does it do?
To build the web page, Drupal queries the site’s database to get menus, blocks, user information, and the main content of a page. All of this is formatted by the site’s modules to create the HTML page that’s returned to the visitor.
By default, Drupal builds a new web page for every visitor. If two visitors ask for the same page, Drupal builds the page twice. To save time, the page cache enables Drupal to save each page the first time it is built. On the second visit, Drupal returns the saved page instead of building it all over again.
The page cache is empty when it is first enabled. As visitors view the site’s pages, Drupal builds and saves the pages into the cache. After awhile, the cache will have most of the site’s popular pages and the site will feel much faster.
Pages in the cache expire and are thrown out after the Minimum cache lifetime. Changes to a cached page will not be seen by visitors until the page expires. To see changes sooner, set the lifetime to a shorter value.
The Caching mode also has an Aggressive setting. When enabled, this slightly improves page load times but it can break some modules. Use it at your own risk.
How well does it work?
With page caching, page load times improved by 30-40%.
Web pages for the complex site include more blocks and require more time to build than for the simple site. Caching these complex pages therefore has a more substantial impact than for the simple site. In general, the more complex the site, the greater the benefit from enabling page caching.
When doesn’t it work?
Drupal’s page cache only works for anonymous visitors (people who don’t log in to the site). For many web sites, nearly all traffic is from anonymous visitors and the page cache is an important way of speeding up the site.
However, the page cache is disabled for logged-in visitors. Each of these visitors may have unique account permissions and preferences that shape how Drupal builds web pages. Since each logged-in visitor may be different, Drupal must generate a custom page for each one. It cannot use the page cache.
Drupal’s page cache works well for anonymous visitors and it is a useful way to improve web site performance. Because logged-in visitors do not benefit from the page cache, it is important to also look at other performance improvements, such as file compression and Drupal’s CSS file aggregation.