Drupal is a registered trademark of Dries Buytaert
cms 2.1.0 Update released for Drupal core (2.1.0)! menu_link_attributes 8.x-1.7 Minor update available for module menu_link_attributes (8.x-1.7). moderated_content_bulk_publish 2.0.51 Minor update available for module moderated_content_bulk_publish (2.0.51). moderated_content_bulk_publish 2.0.50 Minor update available for module moderated_content_bulk_publish (2.0.50). editoria11y 2.2.21 Minor update available for module editoria11y (2.2.21). eca 3.1.0 Minor update available for module eca (3.1.0). sophron 3.1.1 Minor update available for module sophron (3.1.1). ai 1.3.1 Minor update available for module ai (1.3.1). seven 2.0.0-beta6 New beta version released for theme seven (2.0.0-beta6). seven 1.0.1-beta1 First beta version released for theme seven (1.0.1-beta1). paragraphs_entity_embed 4.0.0 Major update available for module paragraphs_entity_embed (4.0.0). bootstrap_italia 2.17.4 Minor update available for theme bootstrap_italia (2.17.4). bootstrap_italia 2.17.6 Minor update available for theme bootstrap_italia (2.17.6). bootstrap_italia 2.17.3 Minor update available for theme bootstrap_italia (2.17.3). solo 1.0.33 Minor update available for theme solo (1.0.33). solo 1.0.32 Minor update available for theme solo (1.0.32). modal_page 5.1.10 Minor update available for module modal_page (5.1.10). sitewide_alert 3.1.1 Minor update available for module sitewide_alert (3.1.1). paragraph_blocks 4.2.2 Minor update available for module paragraph_blocks (4.2.2). config_distro 2.1.0 Minor update available for module config_distro (2.1.0).

Synopsis

Response Filesystem Cache is a highly performant, general-purpose caching engine that allows Drupal to serve API endpoints and dynamic pages at the speed of static files.

By capturing Drupal responses and saving them as physical files in the public filesystem (with dynamically inferred MIME-type extensions), this module allows your web server (Nginx/Apache) to serve subsequent requests directly. This completely bypasses the PHP and Drupal bootstrap process, resulting in microsecond response times for your most heavily trafficked read-only endpoints.

How It Works

Instead of heavily modifying your controllers, this module uses a lightweight Event Subscriber architecture:

  1. Request Interception: When a configured path is requested, the module redirects the user to the expected physical file location.
  2. Web Server Delivery: If the file exists, Nginx/Apache serves it instantly.
  3. Dynamic Generation: If the file does not exist (resulting in a 404), the module catches the exception, processes the original Drupal request, infers the correct file extension using the devanych/mime-types library based on the Content-Type header, saves the file to disk, and delivers the response.
  4. Automatic Invalidation: Whenever standard Drupal caches are rebuilt (e.g., drush cr), the corresponding physical files and directories are automatically purged.

Requirements

  • Drupal 10 or 11
  • devanych/mime-types (^2.1) - Automatically installed via Composer.

Configuration & Usage

This module acts as a silent engine. Out of the box, it does nothing until another module opts-in using Drupal's Plugin Discovery system.

To cache responses from your custom modules, simply create a {module_name}.response_cache.yml file in the root of your module.

Example (store_api.response_cache.yml):

store_api_products:
  # The Drupal path to intercept
  path_prefix: '/api/v1/products/'
  # The physical location to store the generated files
  uri_prefix: 'public://response_cache/store/products/'

store_api_categories:
  path_prefix: '/api/v1/categories/'
  # If uri_prefix is omitted, the system defaults to storing these in a directory 
  # matching the path (e.g., public://api/v1/categories/) with the appropriate 
  # MIME type extension (like .json).

store_static_pages:
  path_prefix: '/pages/'
  # HTML responses here will automatically be stored in public://pages/ 
  # with a .html extension based on their Content-Type.

Once configured and caches are rebuilt, a request to /api/v1/products/shoes will seamlessly generate and serve from public://response_cache/store/products/shoes.json.

Best Practices

For maximum performance, you can configure your web server (Nginx/Apache) with rewrite rules to map the incoming API requests directly to the sites/default/files/... directory. This allows the web server to handle the initial routing without Drupal even handling the first redirect event.

Activity

Total releases
1
First release
Mar 2026
Latest release
1 day ago
Release cadence
Stability
0% stable

Releases

Version Type Release date
1.0.x-dev Dev Mar 31, 2026