- Issue created by @ayalon
- First commit to issue fork.
- Status changed to Needs work
4 days ago 1:04pm 29 April 2025 - 🇬🇧United Kingdom joachim
The caching per-url is definitely going to hurt performance.
But the reason appears to be this that's getting added into the toolbar:
'#attached' => [ 'library' => ['responsive_preview/drupal.responsive-preview'], 'drupalSettings' => [ 'responsive_preview' => [ 'url' => ltrim($url, '/'), ], ], ],
with the $url coming from
$url = $this->getPreviewUrl();
where the value is the current URL, e.g.
Object { url: "node/6506" }
So changing the cache context to 'url.site' means that the first hit to build the toolbar will cache that specific URL, and all subsequent page loads will show the cached data with that URL. That will mean you'll get the wrong page opened in the preview!
The right way to fix this is to either:
- fix the JS so it doesn't need this URL in the settings -- I don't understand why we need to store a value for the current URL, when we can just get it from **the current URL**!
- use a lazy builder for the responsive_preview toolbar item