Drupal is a registered trademark of Dries Buytaert
drupal 10.6.8 Update released for Drupal core (10.6.8)! drupal 11.3.9 Update released for Drupal core (11.3.9)! drupal 11.3.8 Update released for Drupal core (11.3.8)! drupal 11.3.7 Update released for Drupal core (11.3.7)! drupal 11.2.11 Update released for Drupal core (11.2.11)! drupal 10.6.7 Update released for Drupal core (10.6.7)! drupal 10.5.9 Update released for Drupal core (10.5.9)! cms 2.1.1 Update released for Drupal core (2.1.1)! drupal 11.3.6 Update released for Drupal core (11.3.6)! drupal 10.6.6 Update released for Drupal core (10.6.6)! cms 2.1.0 Update released for Drupal core (2.1.0)! linkit 7.0.15 Minor update available for module linkit (7.0.15). views_data_export 8.x-1.10 Minor update available for module views_data_export (8.x-1.10). linkit 7.0.14 Minor update available for module linkit (7.0.14). migrate_tools 6.1.4 Minor update available for module migrate_tools (6.1.4). diff 2.0.0 Major update available for module diff (2.0.0). masquerade 8.x-2.2 Minor update available for module masquerade (8.x-2.2). video_embed_field 3.1.0 Minor update available for module video_embed_field (3.1.0). bootstrap 8.x-3.40 Minor update available for theme bootstrap (8.x-3.40). menu_link_attributes 8.x-1.7 Minor update available for module menu_link_attributes (8.x-1.7).

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 month ago
Release cadence
Stability
0% stable

Releases

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