perf: cache translated chapter responses for 1 hour
Translation content is immutable once generated — add Cache-Control: public, max-age=3600, stale-while-revalidate=86400 to handleTranslationRead so the browser and any CDN reuse the response without hitting MinIO on repeat views. Forward the header through the SvelteKit /api/translation/[slug]/[n] proxy which previously stripped it by constructing a bare Content-Type-only Response.
This commit is contained in:
@@ -1279,6 +1279,10 @@ func (s *Server) handleTranslationRead(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// Translated chapter content is immutable once generated — cache aggressively.
|
||||
// The browser and any intermediary (CDN, SvelteKit fetch cache) can reuse this
|
||||
// response for 1 hour without hitting MinIO again.
|
||||
w.Header().Set("Cache-Control", "public, max-age=3600, stale-while-revalidate=86400")
|
||||
writeJSON(w, 0, map[string]string{"html": buf.String(), "lang": lang})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user