Caching System - Page Cache

Page Cache in Drupal stores the complete HTML response for anonymous users and serves it directly on subsequent requests. This avoids bootstrapping Drupal and rebuilding the page each time, significantly improving performance. It works together with cache tags, contexts, and max-age, and is commonly combined with Redis, Varnish, and CDNs such as CloudFront or Akamai.

Page Cache in Drupal stores the entire HTML response of a page and serves it directly to anonymous users.

Think of it like this:

Instead of cooking the same meal every time a customer orders it, Drupal prepares it once and serves the ready-made version until something changes.

This is one of the biggest performance optimizations in Drupal Core.

Page Cache helps with:

  • faster page load times
  • lower server usage
  • better SEO
  • handling traffic spikes

In Acquia and enterprise Drupal projects, Page Cache is the first layer of performance optimization.


Core Concept

Without Page Cache:

Request
  ↓
Bootstrap Drupal
  ↓
Query Database
  ↓
Build Render Arrays
  ↓
Render HTML
  ↓
Send Response

With Page Cache:

Request
  ↓
Check Cached HTML
  ↓
Cache HIT → Send Response Immediately

Drupal skips almost all processing.


Who Uses Page Cache?

Drupal Page Cache is designed primarily for:

  • anonymous users

Authenticated users usually bypass this cache and use Dynamic Page Cache instead.


Page Cache Architecture

Anonymous User
      ↓
CDN (CloudFront / Akamai)
      ↓
Varnish (optional)
      ↓
Drupal Page Cache
      ↓
Rendered HTML

This creates multiple performance layers.


Real Project Example (Government Site)

On a federal Drupal site:

  • 95% of traffic was anonymous.
  • Homepage contained Views, blocks, and banners.
  • Page Cache stored the fully rendered homepage.

Result:

  • page load dropped from 1.8s to 150ms
  • database load reduced significantly
  • handled high traffic during press releases

How Drupal Stores Page Cache

Default cache bin:

cache_page

Each cache entry stores:

  • full HTML response
  • response headers
  • cache metadata

Cacheability Metadata Still Matters

Even though the full page is cached, Drupal still respects:

  • cache tags
  • cache contexts
  • max-age

If one component has:

$build['#cache']['max-age'] = 0;

The entire page may become uncacheable.

This is called cache bubbling.


Decision Framework

Use Page Cache when:

  • content is public
  • most users are anonymous
  • content is mostly the same for everyone

Avoid relying only on Page Cache when:

  • pages are highly personalized
  • content varies per user

Configuration

Enable in Drupal:

Administration → Configuration → Development → Performance

Or in settings.php with custom backends.

Redis example:

$settings['cache']['bins']['page'] = 'cache.backend.redis';

Response Headers

Drupal sends HTTP headers such as:

Cache-Control: public, max-age=3600
X-Drupal-Cache: HIT

Useful values:

  • X-Drupal-Cache: HIT
  • X-Drupal-Cache: MISS

Integration with CDN

Page Cache works extremely well with:

  • CloudFront
  • Akamai
  • Fastly

Flow:

Drupal Page Cache
   ↓
CDN stores response
   ↓
Global users receive cached page

This is common in Acquia Cloud and AWS-based architectures.


Page Cache vs Render Cache vs Dynamic Page Cache

Cache TypeScopeTypical Users
Render CacheIndividual componentsAll users
Page CacheEntire pageAnonymous users
Dynamic Page CacheEntire page with personalization supportAuthenticated users

Frontend / React Perspective

For headless Drupal:

Drupal API Response
   ↓
Page/API Cache
   ↓
CDN
   ↓
React App

Even if React handles rendering, the API responses can still be cached.


Platform / DevOps Layer

In enterprise environments:

  • Redis stores cache entries
  • Varnish accelerates reverse proxy caching
  • CloudFront/Akamai handles global delivery
  • CI/CD invalidates CDN after deployment

Pipeline example:

Deploy Code
   ↓
Run drush cache:rebuild
   ↓
Invalidate CDN
   ↓
Warm critical pages

Debugging Page Cache

Check headers:

curl -I https://example.com

Look for:

  • X-Drupal-Cache
  • Cache-Control
  • Age

Useful tools:

  • Webprofiler
  • browser dev tools
  • drush cache:get page

Common Production Issues

  • logged-in users not benefiting from Page Cache
  • uncacheable block disables page caching
  • cookies causing CDN bypass
  • max-age too low
  • missing cache tags causing stale content

SEO Benefits

Page Cache improves:

  • Core Web Vitals
  • Largest Contentful Paint (LCP)
  • crawl efficiency
  • search rankings

Fast pages are better for both users and search engines.


Accessibility Benefits

Faster pages help users who:

  • use screen readers
  • have slow connections
  • use older devices

AI & Future Integration

Modern systems use AI to:

  • predict high-traffic pages
  • pre-warm cache
  • optimize TTL values

Example:

  • AI predicts a trending article and warms it across CDN nodes.

Practice Questions

  1. What is Page Cache in Drupal?
  2. Which users benefit most from Page Cache?
  3. What cache bin stores Page Cache entries?
  4. How does Page Cache differ from Render Cache?
  5. What headers indicate a cache HIT?
  6. How does Page Cache improve SEO?

Memory Trick

Page Cache = Full HTML Page
Anonymous Users = Biggest Benefit
Redis = Storage
CDN = Global Delivery
X-Drupal-Cache = HIT or MISS