From d3737dcc178e1b997959d36d28ebd43aa1e3cc20 Mon Sep 17 00:00:00 2001 From: toshinari123 Date: Tue, 2 Jan 2024 15:39:09 +0800 Subject: [PATCH] Add default Cache-Control header --- .gitignore | 3 +-- internal/handler/site/site_handler.go | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index edc180d..2398902 100644 --- a/.gitignore +++ b/.gitignore @@ -6,8 +6,7 @@ *.test *.out go.work - *.local .env dist/ -/book \ No newline at end of file +/book diff --git a/internal/handler/site/site_handler.go b/internal/handler/site/site_handler.go index 3a67dd5..4b001c8 100644 --- a/internal/handler/site/site_handler.go +++ b/internal/handler/site/site_handler.go @@ -73,6 +73,7 @@ func (h *SiteHandler) serveFile(w http.ResponseWriter, r *http.Request) { } if info.Hash != "" { w.Header().Set("ETag", fmt.Sprintf(`"%s"`, info.Hash)) + w.Header().Set("Cache-Control", "public, max-age=31536000, no-cache") } reader := &lazyReader{