From 6623db95747164710412a92e7102d1999564f95c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magnus=20=C3=85hall?= Date: Wed, 22 May 2024 07:58:41 +0200 Subject: [PATCH] Added caching headers for static content --- pkg.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg.go b/pkg.go index 244173c..b7492c2 100644 --- a/pkg.go +++ b/pkg.go @@ -300,6 +300,9 @@ func (service *Service) StaticHandler(w http.ResponseWriter, r *http.Request, se rxp := regexp.MustCompile("^/(css|images|js|fonts)/v[0-9]+/(.*)$") if comp := rxp.FindStringSubmatch(r.URL.Path); comp != nil { + w.Header().Add("Pragma", "public") + w.Header().Add("Cache-Control", "max-age=604800") + r.URL.Path = fmt.Sprintf("/%s/%s", comp[1], comp[2]) p := fmt.Sprintf(service.staticDirectory+"/%s/%s", comp[1], comp[2]) _, err = os.Stat(p)