Caching overview

Caching

One of Drupal’s key strengths is the ability to dynamically generate content, serving up different content depending on the user and the context. In order to dynamically generate the page that is sent to the browser, a series of complex events must be executed, such as the following:

  • Establishing a database connection
  • Loading settings and modules
  • Initializing a user session
  • Mapping the URL to a PHP page callback function to run the application’s business logic
  • Collecting the elements that surround the main content of the page

Most of these steps are executed every time a page is rendered and can take more time than it would take a simple web server to serve a static page.

An effective caching strategy can greatly improve performance by storing pages, page elements, and other resources, so that a cached version, rather than a newly generated version, can be served. Proper use of caches can improve your website's performance by orders of magnitude. It is vitally important to develop a caching strategy that will best meet the needs of your website. Although many view caching as inconvenient and annoying, to improve website performance, you must consider it.

Caching by stack level

To properly configure the largest pieces of caching for your website, you can quickly set up several types that cover the different levels of the stack, including the application, component, and page layers.

Application

There are a number of applications you can use with Drupal to do heavy caching. These can be critical to the response time of very large websites.

Component

User-facing components, such as views and panels, cache information in smaller chunks instead of an entire page. Improving the rendering of a single view or panel, when that component is used on multiple pages, can reduce response time overall. Component-level caching is usually disabled by default, though you can turn it on with some simple configuration changes. For the best results, identify blocks, panels, and views that remain the same across your website, and then cache them aggressively.

Page

This is the most efficient type of caching. Instead of generating pages dynamically with Drupal bootstrap, your server can show static HTML pages to users instead. The entire page is cached, stored and delivered to a user.

Unless your website is one that really needs very fast content updates (such as news updates, stock monitoring, or weather reports), you can get the best results with stronger caching methods. And even in those circumstances, using caching where possible is critical to increase the speed, stability, and scalability of your website.

Other considerations

In addition to caching, there are things you can do to help ready and maintain your cache. Cache warming may be useful when preparing a website for launch or maintenance.

You should review your caching procedures and timing so that your cache does not flush at the same time. This can cause a cache stampede, which can cause serious performance issues with your website.

The following links may be useful for formulating strategies to avoid cache stampedes:

Acquia Support can provide advisory services to help you further assess your website's caching strategy and ensure that your website is set up for an appropriate balance of fresh content and load speed.

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.

Contact supportStill need assistance? Contact Acquia Support