Drupal users are always concerned about the speed of their site for user experience and SEO purposes. At Newpath, we work with Drupal every day and have seen it used in many builds and implementations, where sometimes even drops in performance measured in milliseconds can cost a significant loss in engagement and conversions on content-heavy and high-traffic sites.
The good news is that with the right strategy, you can halve your load times and sometimes even faster and provide your users with a fast, frictionless experience. However, to do this, you need to know how Drupal caching works, what options there are, and how to configure it correctly.
What is caching and why does Drupal need it?
Think for a second about what Drupal does every time someone visits a page on your site: your CMS has to query your database, run PHP code, render your templates, render the output of integrations (like Views, Commerce, or Panels), and finally, piece together all these elements into a full page ready to send back to the browser for display. This is slow, especially if you have a lot of people accessing your site at the same time. Caching gets around this by storing pre-compiled versions of your pages, so your CMS can deliver them immediately rather than rebuilding on every request.
Essentially without caching, Drupal has to rebuild every page from the ground up on each request, which is slow. With caching, it delivers pre-built pages from its cache storage, speeding up load time and server resource usage considerably. This is the case even on small sites, but the difference in impact is exponential on larger, high-traffic sites, where caching is vital to keeping pages fast and servers stable.
Types of caching in Drupal
Drupal has several layers of caching, each with a different use case. Each layer needs to be configured in its own way, so it’s important to understand each type in order to make an informed decision as to what to use on your site.
- Page Cache: The most basic form of caching in Drupal. A full HTML version of the page is stored, and Drupal serves this to anonymous users without rebuilding it first.
- Dynamic Page Cache: For logged-in users. Drupal can’t use the normal Page Cache for authenticated users since these users can often see different content or elements of the site, depending on their role, user profile, or context. Dynamic Page Cache can store unchanging parts of a page, allowing Drupal to skip unnecessary rendering and database queries, even for logged-in users.
- Render Cache: Stores the output of specific components of your page, such as menus, blocks, or Views. Drupal will not need to regenerate these each time the page is loaded.
- Twig Template Caching: Twig is the templating system Drupal uses to render HTML. Twig can also cache compiled versions of your templates, speeding up that process.
- Custom and Module-Based Caching: Some outsourced Drupal modules and APIs will provide their own caching strategies. Views modules, for instance, or third-party integrations, sometimes have specific caching options.
How caching makes your Drupal site load twice as fast
Caching drastically reduces the amount of work Drupal has to do to serve your pages. Instead of having to process multiple layers of logic on each request, it can simply deliver a pre-built version of a page from its cache storage. This has a few key effects that result in faster page loads and a better experience for your users:
- Fewer Database Queries: Drupal’s database is often the slowest part of your architecture, so caching lessens the number of database queries it has to make, as many results have been cached already.
- Less PHP Processing: Drupal is a PHP application. Skipping rendering, templating, and other PHP steps for cached pages saves considerable CPU resources.
- Less Server Load: Fewer queries and less processing mean your web server can handle more users without slowing down.
- Faster TTFB: Time-to-first-byte is your initial response time, which is often the most important factor for users in perceived page speed. Serving pages from cache directly drastically improves this figure.
- Improved Scalability: By caching properly, your site should be much more resilient to traffic spikes caused by events, promotions, or seasonal changes. Sites with many pages or high traffic should plan capacity with caching in mind, since not caching as much or at all means your server or infrastructure has to work exponentially harder as your user base increases.
Common problems that slow down your Drupal cache
Drupal caching is powerful, but it can also be disrupted by a few common issues. The most common causes of caching being slower than it could be on a Drupal site are often custom modules or bespoke functionality that accidentally disable or bypass one or more of its built-in caching layers.
When developers write custom logic that can produce highly dynamic results for a Drupal site, these will often be unable to be cached by it or rendered as static components from the cache. This leads to slower page load times, since it has to skip over the caching layer to generate these components dynamically.
Sites that use lots of custom functionality and depend on personalised or highly dynamic content can see decreased cache performance. By its very nature, this means that Drupal will need to rebuild pages or page fragments more often for logged-in users or users with specific requirements, limiting the scope of reusable cached elements.
Misconfigured reverse proxies and CDNs, such as Varnish or some setups, can also complicate the caching setup. If cache tags and invalidation rules are not set up correctly, your site could be serving stale content, or worse still, bypassing caching completely and having to generate every page from scratch. Another frequent bugbear is developer settings not being fully re-enabled in production. This most commonly happens when Twig debugging or caching options are turned off for development work, and then not toggled back on after the code has been pushed or integrated. Even when working with experienced Drupal developers in Melbourne or otherwise, this type of misconfiguration can still occur under busy release schedules.
How to tell whether your Drupal caching is working
The most obvious sign is to check the performance of your site, if caching is working, you will have noticed that page load times are better. The page should load noticeably faster, particularly after first loading a page, as Drupal no longer needs to rebuild the page from scratch. You should also see a drop in server resource usage; for example, database queries and CPU usage during busy times should drop. This is because Drupal is reusing cached versions of pages and their components rather than generating them on each request.
You can also use the browser developer tools to inspect the caching activity. Headers should show whether the page was served from cache or dynamically generated. Performance testing tools like Google PageSpeed Insights, GTmetrix, and WebPageTest can be used to further validate and test performance. If these show an improvement after enabling or changing settings, it is a good sign that your caching is working as it should be.