Files
botsmann/lib/api
g-butandClaude Opus 4.5 24e7caa1cb perf(api): add HTTP caching headers to reduce database load
Add Cache-Control header support to API response utilities:
- NONE: no-store for mutations and sensitive data
- PRIVATE_SHORT: 1 minute for user-specific data
- PRIVATE_MEDIUM: 5 minutes for less frequent user data
- PUBLIC_SHORT: 5 minutes for public data
- PUBLIC_MEDIUM: 1 hour for semi-static data
- IMMUTABLE: 1 day for truly static data

Apply caching to key routes:
- GET /api/settings: private, 1 min cache
- GET /api/health: public, 5 min cache
- GET /api/documents: private, 1 min cache
- GET /api/stats: private, 1 min cache
- GET /api/conversations: private, 1 min cache
- All mutations (POST/PUT/DELETE): no-store
- All errors: no-store (automatic)

Expected impact: 2-3x reduction in database queries for
repeated requests within cache window.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 12:06:43 +01:00
..