From 5c5a8e187955662754218507579beb5686b5cce2 Mon Sep 17 00:00:00 2001 From: grimlink Date: Mon, 30 Nov 2026 14:02:08 +0100 Subject: [PATCH 1/3] IMP Move the X-Magento-Tags note onto refuseSharing --- Presentation/BarInjector.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 From a72d31ab57cce3089ebdae066931e9397b33f130 Mon Sep 17 00:00:00 2001 From: grimlink Date: Mon, 30 Nov 2026 17:29:22 +0100 Subject: [PATCH 2/3] IMP Explain how the bar works behind Varnish --- CHANGELOG.md | 5 +++++ docs/user-guide.html | 9 ++++++++- docs/user-guide.md | 32 ++++++++++++++++++++++++++++---- 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f2a35ad..3484937 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 explains how the bar and Varnish work together. While the bar is on, Varnish caches nothing, and a + page cached before it was switched on needs a `cache:clean full_page`. + ## [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/docs/user-guide.html b/docs/user-guide.html index b05ba27..58b78f2 100644 --- a/docs/user-guide.html +++ b/docs/user-guide.html @@ -309,6 +309,13 @@

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

+

The bar works behind Varnish, at the cost of Varnish itself. 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 it to Magento instead of caching it, and every page you open carries a bar. While the bar is on, nothing is cached.

+

A page Varnish cached before you switched the bar on is still served from the cache, without a bar. Clean the full page cache after switching it on, which purges Varnish too:

+
bin/magento cache:clean full_page
+

The Page cache section still tells you whether Magento offered a page to Varnish as cacheable, and every reason it was not. To see real Varnish hits, switch the bar off:

+
bin/magento config:set siteation_debugbar/general/enabled 0
+

With a key set, requests without it are ordinary visitors and Varnish caches them as usual. Your own requests may then be served a cached page without a bar.

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 +361,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 before the bar was switched on. Run bin/magento cache:clean full_page; see Behind Varnish. Magento's built in full page cache is different: launch() still runs and the bar is injected over the cached body.

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..902c00b 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 + +The bar works behind Varnish, at the cost of Varnish itself. 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 it to Magento instead of caching it, and +every page you open carries a bar. While the bar is on, nothing is cached. + +A page Varnish cached before you switched the bar on is still served from the cache, without a +bar. Clean the full page cache after switching it on, which purges Varnish too: + +``` +bin/magento cache:clean full_page +``` + +The [Page cache](#page-cache) section still tells you whether Magento offered a page to Varnish +as cacheable, and every reason it was not. To see real Varnish hits, switch the bar off: + +``` +bin/magento config:set siteation_debugbar/general/enabled 0 +``` + +With a key set, requests without it are ordinary visitors and Varnish caches them as usual. +Your own requests may then be served a cached page without a bar. + ## Debugging a live site The configuration switch covers the whole store, which on a live site is the wrong shape: it @@ -758,10 +782,10 @@ 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 before the bar was switched on. Run +`bin/magento cache:clean full_page`; see [Behind Varnish](#behind-varnish). Magento's built in +full page cache is different: `launch()` still runs and the bar is injected over the cached +body. **The bar looks stale after a module update.** Static asset URLs carry the built file's mtime, so a hard reload is enough. From efab8573da3434ddca2ca7a76863a6ae3477e196 Mon Sep 17 00:00:00 2001 From: grimlink Date: Mon, 30 Nov 2026 17:32:07 +0100 Subject: [PATCH 3/3] IMP Recommend the built in page cache over Varnish --- CHANGELOG.md | 4 ++-- docs/user-guide.html | 16 +++++++++------- docs/user-guide.md | 30 ++++++++++++++---------------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3484937..b383720 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,8 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -- The user guide explains how the bar and Varnish work together. While the bar is on, Varnish caches nothing, and a - page cached before it was switched on needs a `cache:clean full_page`. +- 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 diff --git a/docs/user-guide.html b/docs/user-guide.html index 58b78f2..fe08852 100644 --- a/docs/user-guide.html +++ b/docs/user-guide.html @@ -310,12 +310,14 @@

Open

%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

-

The bar works behind Varnish, at the cost of Varnish itself. 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 it to Magento instead of caching it, and every page you open carries a bar. While the bar is on, nothing is cached.

-

A page Varnish cached before you switched the bar on is still served from the cache, without a bar. Clean the full page cache after switching it on, which purges Varnish too:

-
bin/magento cache:clean full_page
-

The Page cache section still tells you whether Magento offered a page to Varnish as cacheable, and every reason it was not. To see real Varnish hits, switch the bar off:

-
bin/magento config:set siteation_debugbar/general/enabled 0
-

With a key set, requests without it are ordinary visitors and Varnish caches them as usual. Your own requests may then be served a cached page without a bar.

+

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)"
@@ -361,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. The page was cached before the bar was switched on. Run bin/magento cache:clean full_page; see Behind Varnish. 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 902c00b..7f58733 100644 --- a/docs/user-guide.md +++ b/docs/user-guide.md @@ -599,28 +599,28 @@ bin/magento config:set siteation_debugbar/general/editor_path_map '/var/www/html ## Behind Varnish -The bar works behind Varnish, at the cost of Varnish itself. 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 it to Magento instead of caching it, and -every page you open carries a bar. While the bar is on, nothing is cached. - -A page Varnish cached before you switched the bar on is still served from the cache, without a -bar. Clean the full page cache after switching it on, which purges Varnish too: +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 ``` -The [Page cache](#page-cache) section still tells you whether Magento offered a page to Varnish -as cacheable, and every reason it was not. To see real Varnish hits, switch the bar off: +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 ``` -With a key set, requests without it are ordinary visitors and Varnish caches them as usual. -Your own requests may then be served a cached page without a bar. - ## Debugging a live site The configuration switch covers the whole store, which on a live site is the wrong shape: it @@ -782,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.** The page was cached before the bar was switched on. Run -`bin/magento cache:clean full_page`; see [Behind Varnish](#behind-varnish). 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.