Skip to content

The X-Pollora-Diagnostics header, the query budgets per page type and the nightly boot, discovery and thumbnail measures of the framework.

The Pollora framework checks its own cost in its browser tests: how many SQL queries each type of page runs, and how long the boot, a cold discovery and a thumbnail take. This page describes the diagnostic header those checks read, the query budgets and the nightly measures. They belong to the framework’s repository (tests/e2e); the header is the part a project can use too.

A request that sends X-Pollora-Diagnostics: 1 gets a report of what it cost, as long as WP_DEBUG is on:

Terminal window
curl -s -H 'X-Pollora-Diagnostics: 1' https://example.test/ | tail -3
curl -sI -H 'X-Pollora-Diagnostics: 1' https://example.test/wp-json/ | grep -i x-pollora-diagnostics

The report holds four values:

KeyMeaning
wordpress_queriesQueries WordPress ran through $wpdb ($wpdb->num_queries)
laravel_queriesQueries Laravel ran, counted on its QueryExecuted event
boot_msMilliseconds from the start of the request to wp_loaded
elapsed_msMilliseconds from the start of the request to the report

Where it appears depends on the response:

  • A REST response carries it in the X-Pollora-Diagnostics response header, as JSON.
  • An HTML page carries it in a trailing comment after the document: <!-- pollora:diagnostics {...} -->. Redirects, JSON, XML (feeds, sitemaps) and plain text never get one, and neither do wp-admin screens and admin-ajax calls.

Nothing is reported unless both conditions hold: WP_DEBUG is true and the request sends the header. A production site, where WP_DEBUG is false, never reports anything, whatever a visitor sends. A request without the header costs nothing: no hook is registered for it. The report does not depend on the debug bar.

tests/e2e/specs/query-budget.spec.ts asks seven types of page for their own cost: home, post, page, archive, 404, search and REST. It fails when one runs more queries than tests/e2e/budgets.json allows, counted separately in WordPress and in Laravel.

  • The margin is zero: counts are deterministic. Fewer queries than the budget passes.
  • 0 is a real limit: a page allowed no Laravel query fails on the first one. null means no budget yet: the page is measured and reported, never failed.
  • Raising a budget is a deliberate edit of budgets.json, reviewed like code. Lowering one keeps a gain.

The budgets are those of the CI site, a fresh install plus the fixtures of the suite. Another site has other counts. The pages measured are /?p=1, /?page_id=2 and /?cat=1, the content WordPress creates on install.

To write the measured counts into budgets.json:

Terminal window
npm run budgets:update # sets E2E_UPDATE_BUDGETS=1, measures, then writes the file

Run it against a site like the CI one, or take the first measure from a green CI run: every run writes test-results/budgets.measured.json and the CI uploads it as the e2e-budgets-measured-* artifact. Commit the result.

The budgets are strict since v13.43.0: home 24, post 20, page 19, archive 26, 404 15, search 22, REST 19 WordPress queries, and 0 Laravel queries on every page. Read tests/e2e/budgets.json for the current values.

tests/e2e/specs/perf-metrics.spec.ts runs only when E2E_PERF=1, which the nightly job sets. It writes perf-metrics.json with three values, each the median of several runs:

MetricMeasures
boot_msA warm boot, up to wp_loaded
cold_boot_msThe first request after php artisan discovery:clear, so with discovery rebuilt from scratch
thumbnail_msGenerating every size of one 2400x1600 JPEG

The job compares them with the last night that passed (bin/perf-compare.ts) and fails when one is more than 10 % slower. The reference is restored through actions/cache. A failing night does not replace the reference, so a regression cannot become the new normal. To accept a slowdown on purpose, delete the perf07-reference-* cache entries.

To run it by hand:

Terminal window
E2E_PERF=1 npx playwright test perf-metrics
node bin/perf-compare.ts current.json reference.json --tolerance=0.1