diff --git a/http/http.go b/http/http.go index 1716f94..4b3f3e0 100644 --- a/http/http.go +++ b/http/http.go @@ -42,7 +42,7 @@ func (h *Handler) Serve() { if err != nil { panic("couldn't open static files") } - router.Use(headersByRequestURI()) + router.Use(enableCachingForStaticFiles()) router.StaticFS("/static", http.FS(static)) router.GET("/", func(c *gin.Context) { c.HTML(http.StatusOK, "index.html", nil) }) @@ -92,7 +92,7 @@ func (h *Handler) Serve() { router.Run(":1323") } -func headersByRequestURI() gin.HandlerFunc { +func enableCachingForStaticFiles() gin.HandlerFunc { return func(c *gin.Context) { if strings.HasPrefix(c.Request.RequestURI, "/static/") { c.Header("Cache-Control", "max-age=86400")