Why Multi-Level Caching Matters for Drupal Performance
Typical scenario: a Drupal site with 10,000 daily visitors starts lagging under peak load. Without caching, each page generates up to 30 SQL queries, and with 1,000 concurrent sessions, CPU limits are exceeded and the site crashes. TTFB spikes to 2 seconds, Core Web Vitals fail. On one project with 50,000 visits per day, we reduced TTFB from 2.5 seconds to 8 ms by implementing multi-level caching. Our team of Drupal experts with 12+ years of experience and 60+ successful caching implementations delivers measurable results.
We encounter this problem dozens of times. The solution is a combination of Internal Page Cache, Dynamic Page Cache, Redis, Varnish, and BigPipe. This stack reduces server load by 90% and cuts TTFB to tens of milliseconds. Optimizing Drupal performance requires understanding how cache tags and invalidation work.
Problems We Solve
- High TTFB — pages are rendered from scratch for each request, even if static. Typical case: Drupal without caching generates a page in 500–1500 ms, of which 300–800 ms are SQL queries.
- Database overload — each render triggers dozens of queries (N+1, unoptimized views). At 100 rps, the database can crash.
- Slow dynamic blocks — personalized elements (cart, user bar) block rendering. BigPipe solves this with streaming rendering.
Caching Architecture
Drupal is one of the few CMS with built-in cache support at the kernel level. We use four levels:
Render Cache
Caches individual render arrays (blocks, views, fields). Invalidated by cache tags. Example: the latest news block is cached for 1 hour and invalidated when a new article is published.
Dynamic Page Cache
Caches pages with context (logged in/out, language, role). Does not run the full bootstrap but still hits PHP. Typical TTFB: 50–200 ms.
Internal Page Cache
Full page cache for anonymous users. Stores HTML on disk/in database. Enabled via admin or drush:
drush en page_cache -y
drush cr
Configuration: system.performance > cache.page.max_age = 3600.
More on Varnish configuration for high-traffic projects
Varnish acts as a reverse proxy in front of Nginx/Apache. It caches responses and invalidates them via cache tags when content is published. Using Varnish Drupal integration with the Purge module ensures cache tags are respected for granular invalidation. Basic VCL configuration:
vcl 4.1;
import std;
backend default {
.host = "127.0.0.1";
.port = "8080";
}
sub vcl_recv {
if (req.http.Cookie ~ "SESS|SSESS") { return(pass); }
if (req.method != "GET" && req.method != "HEAD") { return(pass); }
unset req.http.Cookie;
return(hash);
}
sub vcl_backend_response {
set beresp.ttl = 1h;
set beresp.grace = 1h;
return(deliver);
}
sub vcl_deliver {
set resp.http.X-Cache = obj.hits > 0 ? "HIT" : "MISS";
}
Varnish employs hash-keys based on URL and cache headers, with grace mode for stale-while-revalidate and saint mode for backend health checks. For integration, we use the Purge module:
composer require drupal/varnish_purger drupal/purge
drush en purge purge_drush purge_ui purge_queuer_coretags purge_processor_cron varnish_purger -y
According to Wikipedia, Varnish employs granular cache tags for precise invalidation, crucial for Drupal performance optimization.
Which Performance Metrics to Track?
Monitor TTFB, SQL query count, cache hit ratio (HIT/MISS), LCP, CLS. Tools: Devel, XHProf modules, X-Cache headers from Varnish. Aim for TTFB below 200 ms and cache hit ratio exceeding 90%. On one project after optimization, TTFB dropped from 1.2 s to 12 ms, and SQL queries from 250 to 3 per page. Our team with 60+ Drupal performance projects achieves average TTFB reduction of 95%. For a typical Drupal site with 50k visitors/day, multi-level caching saves $3,000/month on hosting costs.
How Drupal Caching Configuration Affects Core Web Vitals
Properly configured caching directly improves LCP and INP. When a page is served from the Varnish cache, LCP drops to 500–800 ms, and INP improves due to elimination of long server tasks. For authenticated users, BigPipe splits rendering into streams, reducing time to first content.
Configuring Redis for Drupal
Install the Redis module, set parameters in settings.php:
$settings['redis.connection']['interface'] = 'PhpRedis';
$settings['redis.connection']['host'] = 'localhost';
$settings['cache']['default'] = 'cache.backend.redis';
$settings['cache']['bins']['render'] = 'cache.backend.redis';
$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.redis';
After that, cache bins are offloaded to Redis, reducing database load by 70–90%. Configuring Redis for Drupal caching offloads database queries and improves Drupal performance, especially when combined with OPcache Drupal. OPcache accelerates PHP script execution by 30–50%.
What's Included in the Work
- Audit of current architecture (logs, configs, load).
- Implementation of all caching levels (Internal Page Cache, Dynamic Page Cache, Redis, Varnish, BigPipe).
- Configuration of PHP OPcache and CSS/JS aggregation.
- Maintenance documentation and deployment recommendations.
- Performance guarantee: TTFB <200 ms under typical load.
- Team training on cache management and monitoring.
- Over 60 projects optimized, average TTFB reduction of 95%.
Infrastructure cost savings can reach 80% due to reduced server load. Investment in optimization typically pays back in 2–3 months. Optimization packages start at $1,500.
Process and Timeline
- Analysis — study current architecture, logs, configs (1 day).
- Design — choose stack: Varnish vs Nginx cache, Redis vs Memcache (1 day).
- Implementation — configure caching, BigPipe, Purge (2–3 days).
- Testing — load testing, Core Web Vitals measurement (1 day).
- Deployment — roll out to production, documentation (1 day).
Typical timelines: basic optimization — 2–3 days, with Varnish — 5–7 days. Pricing is calculated individually. Contact us for a detailed audit.
Typical Optimization Results
| Configuration | TTFB | SQL Queries |
|---|---|---|
| No cache | 800–2000 ms | 100–300 |
| Dynamic Page Cache | 50–200 ms | 5–20 |
| Varnish (anonymous) | 1–5 ms | 0 |
| Redis + OPcache | 100–300 ms | 5–15 |
Varnish is roughly 10x faster than Dynamic Page Cache for anonymous requests.
Comparison of Caching Methods
| Method | Cache Type | Best For |
|---|---|---|
| Internal Page Cache | Full page | Anonymous users |
| Dynamic Page Cache | Page with context | All users (with context) |
| Varnish | External cache | Anonymous, preloading |
| Redis | Binary cache | All bins, database offload |
According to Wikipedia, BigPipe is a streaming rendering technology that minimizes time to first content for authenticated users.
Our team has over 10 years of Drupal experience and has completed 50+ performance optimization projects. Order a Drupal performance audit today and get a free consultation for your project.







