fix(preview): stop caching the embedding verdict indefinitely#2012
Conversation
Hugo caches remote resources forever by default (caches.getresource maxAge -1), and the Netlify cache plugin carries that cache from build to build. The preview component reads a target's response headers to decide whether it can be embedded, so a stale entry pins the verdict to whatever the target sent the first time it was fetched. That is not hypothetical: the showcase previews on gethinode.com stayed on their fallback screenshots after both sides of the embed were corrected and the site was rebuilt, because the build re-read the old headers out of the cache. Recovering needs a cache-cleared deploy, and nothing in the build says so. Cap the lifetime at 5 minutes. Builds are further apart than that, so the headers are re-read on every build, while a single build still fetches each one only once. Also upgrade mod-leaflet to v3.1.0, which gives the map cooperative gestures: the map on /docs/components/map trapped page scroll until now. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
✅ Deploy Preview for gethinode-demo ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
v1.15.1 documents the cooperative gestures that mod-leaflet v3.1.0 introduces, so the demo's map page describes the behaviour it now has rather than the behaviour it used to have. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Added: mod-docs v1.15.1Bumped mod-docs to v1.15.1, which documents the cooperative gestures that mod-leaflet v3.1.0 The documentation change (gethinode/mod-docs#115) had merged without a release: Verified on the exampleSite build: the map page now documents the gestures, and |
|
🎉 This PR is included in version 3.0.3 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Problem
Hugo caches remote resources forever by default (
caches.getresourcemaxAge = -1), andnetlify-plugin-hugo-cache-resourcescarries that cache from build to build.The preview component reads a target's response headers to decide whether it can be embedded — so a
stale cache entry pins the verdict to whatever the target sent the first time it was fetched.
Correcting a target's CSP then has no effect on a rebuild.
This is not a theoretical risk. After gethinode/gethinode.com#154, #2008 and
gethinode/theme-agency#384 all merged and deployed, the Agency and Hinode (classic)
showcases stayed on their fallback screenshots, even though:
demo.gethinode.comandtheme-agency.gethinode.comnow sendframe-ancestors 'self' gethinode.comframe-srcallows themThe rebuild re-read the old headers out of the cache. Recovering requires a cache-cleared deploy,
and nothing in the build output says so — it just silently keeps showing screenshots.
Change
Cap the lifetime of the remote-resource cache:
Builds are further apart than five minutes, so headers are re-read on every build, while a single
build still fetches each one only once.
getresourcealso backs remote images (mod-utils) and videoposters (hinode), so the cache is shortened rather than disabled — those are re-fetched per build,
not per use.
Also upgrades mod-leaflet to v3.1.0 (gethinode/mod-leaflet#266), which gives the map cooperative
gestures. The map on
/docs/components/maptrapped page scroll until now; gethinode.com already hasthis bump, the demo did not.
Verification
Built the exampleSite with the new module vendored:
[caches.getresource] maxage = '5m0s'.data-leaflet-hint-zoom,data-leaflet-hint-drag),and the overlay styles compile into the leaflet CSS bundle.
i18nmount for the first time, so I checked it resolves: a Dutch page renders"Gebruik twee vingers om de kaart te verplaatsen".netlify.tomlis unchanged — neither change affects the published headers.🤖 Generated with Claude Code