`npm run dev` keeps serving old images from `/api/og` after a template change
Maintainer antworten meist innerhalb von 1 Tag
Bewertung
Dieses Issue wurde noch nicht bewertet.
Beschreibung
/api/og and /api/templates/<id>/thumbnail.png keep every 200 in caches.default. The comment above that code says the cache doesn't exist in astro dev, but in npm run dev it does: the Cloudflare adapter gives the dev server a caches.default, and it's kept on disk in .wrangler/state/v3/cache.
So if you change a template and reload the same /api/og?template=... URL, you get the old image back, even after restarting the dev server. Add any extra param (&v=2) and the new one shows up. The editor's live preview isn't affected (it renders in the browser), but Download PNG and the gallery thumbnails are.
What to do
- Skip the cache in dev in both routes, for example
import.meta.env.DEV ? undefined : (globalThis.caches ...)?.default - Update both comments to match
Where to look
src/pages/api/og.ts(lines 15 to 21 and 93) andsrc/pages/api/templates/[id]/thumbnail.png.ts(lines 11 to 17 and 44)tests/api/og.test.ts, the "OG API error caching" block. In vitestimport.meta.env.DEVistrue,vi.stubEnv('DEV', false)turns it off, andvi.stubGlobal('caches', { default: { match: vi.fn(), put: vi.fn() } })gives you a cache to check
Acceptance criteria
- In dev, neither route reads from or writes to the cache
- Outside dev, a 200 is still cached like before
- Tests for both cases, and the dev one fails on the current code
-
npm run check,npm run testandnpm run buildpass
Want to work on this? Comment below and I'll assign it to you. Please take one issue at a time, branch off dev, and open your PR against dev with Closes #228 in the description.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 8
- Forks
- 4
- Ø Merge
- 8 Std. 44 Min.
- Gemergte PRs (30 T.)
- 159
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus codercops/ogcops
-
bug good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
codercops/ogcops#394 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Preview checker: a `<title>` written over several lines keeps its line break and indentationEvtl. vergeben @bhushan4work hat das vor 1 Tag übernommen. Offenbug good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
codercops/ogcops#393 · 1 Kommentar · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
[Bug] “Copy Recommended Meta Tags” generates an unusable placeholder image URLEvtl. wieder frei @CreatorguyS hat das vor 7 Tagen übernommen, und es ist kein Pull Request offen. Offenbug enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
codercops/ogcops#378 · 4 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Preview checker: named entities like `’` and `—` show up as raw textEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offenbug good first issue
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
Add the Do and Don't tutorial template (`tutorial-do-dont`)Evtl. vergeben @Ravindar-Amogh-Gummadavelly hat das vor 7 Tagen übernommen. Offengood first issue templates
codercops/ogcops#355 · 2 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in codercops/ogcops
Ähnliche Issues
-
area:frontend kind:bug priority:p2 ready
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
handsontable/hyperformula#1879 ·
Maintainer antworten meist innerhalb von 1 Tag
-
enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
RunestoneInteractive/rs#1661 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
capricorn86/happy-dom#2594 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
Maintainer antworten meist innerhalb von 1 Tag