Open maxfenton opened 1 year ago
Joshua correctly pointed out that I was mis-reading (!empty($request->getParam('no-cache')))
as checking a Header when it is checking a GET
param. setNoCacheHeaders()
will not work.
Can we do a check in the module to see if Blitz exists and if it does, only output this if the Debug Toolbar is also visible?
isPluginEnabled()
https://docs.craftcms.com/api/v4/craft-services-plugins.html#method-ispluginenabled
$user = Craft::$app->getUser()->getIdentity();
if ($user !== null) && ($user->getPreference('enableDebugToolbarForSite')) { ... output the button }
👏 This seems good to go in https://github.com/vigetlabs/craft-viget-base/commit/605fb745e5b95f37e359f70ca1b1067ce4c48f62
The red "Edit Entry" sometimes ends up in Blitz or CDN cached versions of the site.
We should explore a few different options to prevent this from happening when content editors view the front-end of the site.
There are a few caching layers
Change to Viget.com module code (no-cache headers for admins)
Details: Across a few sites that use this module with the Blitz plugin (e.g. ADC-AMH, Viget) sometimes the
Edit Entry
button gets cached in the Blitz static cache for all users.It was a misunderstanding that Blitz automatically does not cache or serve cached assets to signed-in users, but in looking at the source code the logic is as follows:
Blitz is only checking:
($user !== null) && (!Craft::$app->getIsLive() && !$user->can('accessSiteWhenSystemIsOff'))
($user !== null) && ($user->getPreference('enableDebugToolbarForSite'))
(!empty($request->getParam('no-cache')))
($request->getToken() !== null && !$this->getIsGeneratorRequest())
During development, Viget developers (cough me) have the debug toolbar visible so the caching issue was not immediately evident or consistent. Seeing that this Blitz logic checks for the
no-cache
header, add a no-cache header to all pages that show the Edit Entry buttonLooking at the Craft 4 code for
Response
there may be a public functionsetNoCacheHeaders()
or else the module might need to do something likeRef: