Smartly control what gets cached — and keep your Drupal database clean.

Page Cache Exclusion gives you fine-grained control over Drupal’s internal page cache system. Instead of letting every page (including 404 errors, unwanted URLs, or dynamically generated content) clutter your cache table and bloat your database (huge cache_page table in Drupal), this module lets you exclude specific paths or patterns from being cached.

What it does

  • ✅ Excludes specified paths from being cached by the internal page cache system.
  • 🧹 Prevents unnecessary cache entries (like 404 pages or bots hitting invalid URLs) from filling up your database.
  • 🧠 Helps improve overall performance and keeps your cache table lean and efficient.

Why use it?

Drupal’s default internal page cache (cache_page table in the database) can sometimes work too well — even caching pages that you don't want cached, like:

  • 404 pages
  • Spam or bot traffic
  • Dynamic or frequently changing content (Pages with exposed filters, views, ...)
  • Custom sections of your site where caching is problematic

This module lets you avoid unnecessary cache bloat and gives you more control over performance tuning, especially on high-traffic or complex sites.

Benefits

  • Cleaner and smaller cache tables
  • Better database performance over time
  • Easy configuration of path-based cache exclusion
  • Peace of mind for devs and site maintainers

How to use

1. Install the module

Via Composer:

composer require drupal/page_cache_exclusion

Then enable it:

drush en page_cache_exclusion

Or enable it from the Extend admin UI directly from the Drupal backoffice.

2. Configure Path Exclusions

Go to /admin/config/development/performance/page_cache_exclusion (also available via Configuration > Development > Page Cache Exclusion)
You’ll see a simple form where you can define one URL path per line. You can use:

  • a) Exact paths (/some/path)
  • b) Wildcards (/some/*/pattern)
  • c) Regular expressions (/^node\/[0-9]+/)

The first field "Exclude cache for page variation with query parameters" helps you exclude pages where query parameters are present, for example, the /search page of your website contains exposed filters that, when clicked, redirect to URLs like /search?filter1=xxx&filter2=ZZZ . To exclude all these generated URLs you cam simply add the line /search to this field. (NB: This doesn't exclue the page /search itself!)
The second field, "Paths to exclude", is used to exclude a whole page.
You can also check the field "Disable caching 4xx responses" to exclude caching of all pages with 4XX responses (usually robots or old pages)

3. Save and Test

Usage example

/mypage/xxx
/yyyypage/*
/search/*
/myform/
Supporting organizations: 
funding of the module stable release

Project information

Releases