diff --git a/CHANGELOG.md b/CHANGELOG.md index f2a35ad..b383720 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [Unreleased]: https://github.com/Siteation/magento2-debugbar/compare/1.6.0...main +### Changed + +- The user guide recommends Magento's built in full page cache over Varnish while the bar is on. Varnish caches nothing + while the bar is on, and a page it cached before hides the bar. + ## [1.6.0] - 2026-11-20 [1.6.0]: https://github.com/Siteation/magento2-debugbar/compare/1.5.3...1.6.0 diff --git a/Presentation/BarInjector.php b/Presentation/BarInjector.php index 22d3e39..e2672f4 100644 --- a/Presentation/BarInjector.php +++ b/Presentation/BarInjector.php @@ -119,11 +119,6 @@ public function inject(ResponseInterface $response, array $profile): void $response->clearHeader('Content-Length'); } - /** - * X-Magento-Tags goes with it: Magento's own Varnish configuration decides a response is - * cacheable by the presence of that header, so leaving it would leave the decision to a - * rule that never heard of this module. - */ /** * @param array $profile */ @@ -138,6 +133,11 @@ private function label(array $profile): ?string return trim(sprintf('%s %s', $magewire['component'], $magewire['action'] ?? '')); } + /** + * X-Magento-Tags goes with it: Magento's own Varnish configuration decides a response is + * cacheable by the presence of that header, so leaving it would leave the decision to a + * rule that never heard of this module. + */ private function refuseSharing(HttpResponse $response): void { // The same directives Magento's own setNoCacheHeaders() sends, and deliberately not diff --git a/docs/user-guide.html b/docs/user-guide.html index b05ba27..fe08852 100644 --- a/docs/user-guide.html +++ b/docs/user-guide.html @@ -309,6 +309,15 @@

Open bin/magento config:set siteation_debugbar/general/editor_template 'myeditor://open?file=%f&line=%l'

%f is the absolute file and %l the line. Paths are stored relative to the application root and the link is built in the browser, so your editor never ends up inside a stored profile. If the application runs somewhere your editor cannot see, a container for instance, map the root:

bin/magento config:set siteation_debugbar/general/editor_path_map '/var/www/html:/Users/you/dev/shop'
+

Behind Varnish

+

Switch the store to Magento's built in full page cache while you use the bar. It still caches, the bar is injected over a cached page, and the Page cache section can tell you the page was served from the cache:

+
bin/magento config:set system/full_page_cache/caching_application 1
+bin/magento cache:clean full_page
+

Varnish gains nothing with the bar on. Without a key every request from a local or private address gets the bar, and the address Varnish connects from is one. A page with the bar is marked no-store, so Varnish passes every request to Magento and caches nothing. A page it cached before the bar was switched on is still served from the cache, without a bar.

+

To test Varnish itself, switch the bar off and Varnish back on:

+
bin/magento config:set siteation_debugbar/general/enabled 0
+bin/magento config:set system/full_page_cache/caching_application 2
+bin/magento cache:clean full_page

Debugging a live site

The configuration switch covers the whole store, which on a live site is the wrong shape: it would turn the bar on for every visitor. The access key is the per request half.

bin/magento config:set siteation_debugbar/general/access_key "$(openssl rand -hex 32)"
@@ -354,7 +363,7 @@ 

What it costs

The bar itself embeds about 1.5 kB of summaries in the page and fetches sections on demand.

Troubleshooting

No bar on the page. In order: is it enabled, is the area on the list, is your address on the allowlist, and outside developer mode is a key set and presented. A response that was profiled carries X-Siteation-DebugBar-Profile even when it cannot carry a bar, so the header tells you which half is failing.

-

No bar behind Varnish. A Varnish hit never reaches PHP, so no profile is written on ordinary catalog and CMS pages. You will see the bar on pass-through pages: customer, checkout, POSTs. Magento's built in full page cache is different: launch() still runs and the bar is injected over the cached body.

+

No bar behind Varnish. The page was cached by Varnish before the bar was switched on. Switch to the built in full page cache; see Behind Varnish.

The bar looks stale after a module update. Static asset URLs carry the built file's mtime, so a hard reload is enough.

A profile id returns "not found". It has expired. Profiles last 20 files or 60 minutes, and both bounds are enforced on read.

Findings look wrong after changing a threshold. Thresholds are read when the profile is written, not when it is displayed. Load the page again.

diff --git a/docs/user-guide.md b/docs/user-guide.md index f8defa6..7f58733 100644 --- a/docs/user-guide.md +++ b/docs/user-guide.md @@ -597,6 +597,30 @@ map the root: bin/magento config:set siteation_debugbar/general/editor_path_map '/var/www/html:/Users/you/dev/shop' ``` +## Behind Varnish + +Switch the store to Magento's built in full page cache while you use the bar. It still caches, +the bar is injected over a cached page, and the [Page cache](#page-cache) section can tell you +the page was served from the cache: + +``` +bin/magento config:set system/full_page_cache/caching_application 1 +bin/magento cache:clean full_page +``` + +Varnish gains nothing with the bar on. Without a key every request from a local or private +address gets the bar, and the address Varnish connects from is one. A page with the bar is +marked `no-store`, so Varnish passes every request to Magento and caches nothing. A page it +cached before the bar was switched on is still served from the cache, without a bar. + +To test Varnish itself, switch the bar off and Varnish back on: + +``` +bin/magento config:set siteation_debugbar/general/enabled 0 +bin/magento config:set system/full_page_cache/caching_application 2 +bin/magento cache:clean full_page +``` + ## Debugging a live site The configuration switch covers the whole store, which on a live site is the wrong shape: it @@ -758,10 +782,8 @@ the allowlist, and outside developer mode is a key set and presented. A response profiled carries `X-Siteation-DebugBar-Profile` even when it cannot carry a bar, so the header tells you which half is failing. -**No bar behind Varnish.** A Varnish hit never reaches PHP, so no profile is written on -ordinary catalog and CMS pages. You will see the bar on pass-through pages: customer, -checkout, POSTs. Magento's built in full page cache is different: `launch()` still runs and -the bar is injected over the cached body. +**No bar behind Varnish.** The page was cached by Varnish before the bar was switched on. +Switch to the built in full page cache; see [Behind Varnish](#behind-varnish). **The bar looks stale after a module update.** Static asset URLs carry the built file's mtime, so a hard reload is enough.