This project is not covered by Drupal’s security advisory policy.
Request Inspector shows a developer what happened during their own requests, on any site, including a live one: database queries, outbound HTTP calls, PHP errors and deprecations, log entries and timing, and in plain words why a page was or was not cached.
Status: Stable, for production use. 1.0.0 is the first release. Please report anything that does not behave as described in the issue queue.
Why
Most profilers inject a toolbar into the page and collect data on every request, so they are kept off production sites, where the slow pages and the cache misses actually are. Request Inspector is off for everyone. A developer with a restricted permission turns it on for their own requests, for a limited time, and reads what was captured on a separate page. The inspected page's markup and its cache entries are never changed, and every other request pays one check of a header and of session data already in memory.
Features
Cacheability, in plain words
- Why Dynamic Page Cache did or did not store the page, what Page Cache does for anonymous visitors, and what the
Cache-Controlheader tells browsers and CDNs. Drupal's own verdict, theX-Drupal-Dynamic-Cacheheader, is the answer; the inspector explains which part of the page caused it. - The blocks, entities, views and elements responsible are named: the part with max-age 0, the part that varies per user, the code that triggered the page cache kill switch (with its call stack), a session started for an anonymous visitor, and what became a placeholder and why.
- Check as an anonymous visitor renders the same path logged out, without logging you out, and explains what anonymous visitors get. It runs inside the site as a sub-request and never makes an HTTP request.
Queries, calls, errors and timing
- Database queries: count and time, duplicates, the same query repeated with different values (the usual sign of loading things one at a time), slow and failed queries, and the code and module that ran each one.
- Outbound HTTP calls made through Drupal's HTTP client, with their timing, status and timeout. Slow calls are flagged, and so are calls with no timeout or one over 10 seconds.
- PHP errors, exceptions and deprecations, including the silenced deprecations a Drupal 12 upgrade needs to see, grouped by the code that calls the deprecated API.
- Log entries written during the request, memory and peak memory, and a timeline of the time spent in each kernel event listener. Each hook implementation can be timed too, with a setting in
settings.php. - AJAX and HTMX requests are captured like pages, with the page they came from. Inspected responses carry a
Server-Timingheader for the browser's developer tools.
Built for live sites
- Off for everyone by default. Turned on per developer, from the Request inspector page, for 60 minutes by default; an administrator can turn it off for everyone at once.
- On requests nobody inspects, the module runs one check of a header and of the session. Measured inside real requests in the module's benchmark, that costs about 3 µs for an anonymous visitor and 6 µs for a logged-in user. Pages served from Drupal's page cache never reach it.
- Captures are read on their own page, which lists new ones as they arrive and can be paused. A capture belongs to the developer who made it, and only they can open it on the site.
- Each capture has a hard size cap (1 MB by default). Past it, detail is given up in a fixed order and the capture says what was left out. Captures are kept in expirable storage (60 minutes and 50 per developer by default) and removed automatically.
- Credentials, cookies, CSRF tokens, session data and other recognizable secrets are redacted before a capture is stored, wherever they turn up in it. See "What a capture holds" below.
API clients, scripts and Drush
- A client without a browser session (curl, a decoupled front end, a test script) sends a signed token in the
X-Request-Inspectorheader. The token works only together with the same account's usual credentials. - Drush commands:
request-inspector:status,request-inspector:token <user>,request-inspector:list <user>,request-inspector:show <user> <token>(with--format=jsonor--full) andrequest-inspector:reset. Together they make a performance budget scriptable: request a page, read its capture, and fail the build if the query count or the time is over budget. - For other modules: an event when an inspection starts, so they can collect data of their own, and an event when a capture is complete, to add a section to it.
Requirements
- Drupal 11.3 or later, or Drupal 12.
- PHP 8.3 or later.
- No other modules. Page Cache and Dynamic Page Cache are explained when they are enabled; BigPipe is supported. Drush 13 is optional, for the commands.
- The module runs no SQL of its own: captures go in Drupal's expirable key-value storage. Tested on MariaDB and SQLite.
Installation
Install with Composer, then enable the module:
composer require drupal/request_inspector drush en request_inspector
Nothing is captured until a developer with the permission turns it on.
Configuration and permissions
Developers turn the inspector on and read their captures at Reports » Request inspector (/admin/reports/request-inspector). Limits and retention are at Administration » Configuration » Development » Request inspector (/admin/config/development/request-inspector).
- Use the request inspector (restricted): turn the inspector on for your own requests, create tokens for API clients, run the anonymous check, and read your own captures. Captures hold database queries with their values, request headers and log messages, so give it only to trusted developers.
- Administer the request inspector (restricted): change the capture limits and retention, turn the inspector off for everyone and delete every captured request. It does not open other developers' captures.
The status report shows an error if either permission is granted to the anonymous or authenticated role, and the inspector refuses the anonymous account in any case. Hook timing is turned on in settings.php with $settings['request_inspector_hook_timing'] = TRUE;. It adds one check to every hook call on the site, for everyone, which is why it is off by default.
What a capture holds
A capture holds the developer's own request: its database queries with their values, request and response headers, outbound calls, errors and log messages. Request and response bodies are never stored. Before a capture is stored, the inspector redacts:
- headers and query parameters whose names look like credentials (containing
token,secret,passw,session,cookie,authorization,csrforapi-key, ending inkey, and similar); - values that look like credentials whatever they are called: HTTP authentication schemes such as Basic and Bearer, JSON Web Tokens, and common API key shapes;
- the secret part of core's one-time login, account cancellation and cron URLs;
- every value of a query on the sessions table, and anything that looks like a password hash;
- each secret found this way, wherever else it appears in the capture: in query values, log lines, errors and outbound URLs.
Secrets in other shapes may not be recognized: a custom header or parameter with an ordinary name, a token shorter than six characters, or a secret in the path of another module's page or of an outbound call. Turn off Record query values to keep every query value out. The README sets out the full rule.
Known limitations
- Queries and time before the inspector's middleware runs (loading the container, reading the session) are not recorded; the capture says how long that was.
- Work done after the response is sent, such as automated cron, queues and indexing at the end of a request, is left out of the capture by design: it belongs to no request in particular.
- HTTP clients created with
new Client()instead of Drupal'shttp_clientservice or its factory are not seen. - Only kernel event listeners are timed unless more events are listed in the
request_inspector.timed_eventscontainer parameter. Hook timing is unavailable, and the status report says so, if another module replaced core's module handler or core changed the parts of it that hook timing relies on. - If a module creates Drupal's renderer before the inspector's middleware runs, the page's parts cannot be seen one by one. The capture says so; the verdicts are still right.
- The anonymous check renders the page for real, so anything the page does on view, such as a view counter, happens.
- With BigPipe, streamed placeholders are in the capture, but the
Server-Timingheader is sent before them. - On Drupal 11.3, a 403 or 404 page carries its error sub-request's Dynamic Page Cache header, so the capture explains the sub-request's verdict.
- Database errors raised while a statement is prepared, before it runs, reach no event in core and are not recorded as failed queries.
- Expired captures leave the database only when cron runs. The status report warns when captures are stored and cron has not run for a day.
- An inspected request costs the inspected developer more: in the module's benchmark, about 12 to 15 µs and 1.5 KiB of memory per recorded query with the default settings. Turn off Record call stacks for very query-heavy pages.
Similar projects
Checked on drupal.org in November 2026.
- WebProfiler is a Symfony-style profiler toolbar with many collectors, among them services, forms, routing and views. Choose it on a development site for that breadth. It collects and stores a profile for every request while installed, injects a toolbar into the page, and its README says it must not be used in production. Its latest release, 11.2.3, declares Drupal 11.
- Devel provides dumpers and developer links, and no longer has a query log or timer. Use it alongside this module.
- Cache Explain places a block that sends a HEAD request to the page's own URL and reports what the browser, a CDN, Varnish, Page Cache and Dynamic Page Cache did for an anonymous request. Choose it to see the layers in front of Drupal, which this module never contacts. It says what each layer did rather than which element caused it, and its block changes the page it explains. It is an alpha for Drupal 10.3 and 11.
- Render Visualization lets you query a page's elements by cache contexts, tags or max-age from the browser console. Choose it to explore a render tree interactively. Its renderer decorator is in every request's render path while it is installed.
- Cache review reviews render cacheability through decorators that stay on while it is installed. It is no longer developed, and its latest release is a 2024 release candidate.
- WordPress's Query Monitor is the model for this module's panels. Application monitoring services such as New Relic trace sampled transactions on every request across a site's servers, and explain time, not cacheability. Choose one for site-wide monitoring; this module answers questions about one developer's own requests.
Support and maintenance
Report bugs and ask for features in the issue queue. Each release has notes describing what changed.
This project is not covered by Drupal's security advisory policy. Until it is, security issues are handled in the public issue queue and fixed in ordinary releases.
Maintainer
Created and maintained by deadnorth (Dead North).
Project information
- Project categories: Developer tools, Performance
- Created by deadnorth on , updated
This project is not covered by the security advisory policy.
Use at your own risk! It may have publicly disclosed vulnerabilities.
