From 8452f320ea1b9b7bcbd7e96fe29d015ac2ded4cc Mon Sep 17 00:00:00 2001 From: Fredrik Johansson Date: Fri, 7 Aug 2026 14:38:51 +0200 Subject: [PATCH] Mark /api/caption uncacheable Same date can legitimately draft different captions call to call (goonk's git/spotify state changes through the day, phrasing itself is randomized), but nothing told any proxy/CDN layer between the browser and this response that it shouldn't cache by URL. Explains the deployed-vs-goonk staleness discrepancy: goonk's own endpoint may have different (or no) caching rules than whatever fronts postcard. Co-Authored-By: Claude Sonnet 5 --- server/src/routes.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/src/routes.js b/server/src/routes.js index 360f2a0..e5fa94b 100644 --- a/server/src/routes.js +++ b/server/src/routes.js @@ -14,7 +14,13 @@ const ALLOWED_MIME = new Set(['image/jpeg', 'image/png', 'image/webp']) // GET /api/caption?date=YYYY-MM-DD — draft a one-line caption from that // day's context. Editable client-side before it's ever composited in. +// Explicitly uncacheable: the same date can legitimately draft a +// different caption call to call (goonk's underlying git/spotify state +// changes through the day, and the phrasing itself is randomized), so any +// browser/CDN/reverse-proxy layer caching this by URL would silently +// serve stale activity data. apiRouter.get('/caption', async (req, res) => { + res.setHeader('Cache-Control', 'no-store') const date = /^\d{4}-\d{2}-\d{2}$/.test(req.query.date) ? req.query.date : new Date().toISOString().slice(0, 10) const caption = await draftCaption(date) res.json({ caption })