Mark /api/caption uncacheable
Docker / build-and-push (push) Successful in 4m23s

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 <noreply@anthropic.com>
This commit is contained in:
Fredrik Johansson
2026-08-07 14:38:51 +02:00
co-authored by Claude Sonnet 5
parent e5c242418f
commit 8452f320ea
+6
View File
@@ -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 })