From 5f4ebeba9573a1dc7f089cc8325a4a022976a212 Mon Sep 17 00:00:00 2001 From: Justin Cranford Date: Sun, 29 Sep 2024 04:11:13 -0400 Subject: [PATCH] server: add "Cache-Control: max-age=0" response header --- server/routes.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/server/routes.go b/server/routes.go index 6bd3a93f..6bd0c630 100644 --- a/server/routes.go +++ b/server/routes.go @@ -1092,6 +1092,13 @@ func allowedHostsMiddleware(addr net.Addr) gin.HandlerFunc { } } +func CacheControlMiddleware() gin.HandlerFunc { + return func(c *gin.Context) { + c.Header("Cache-Control", "max-age=0") + c.Next() + } +} + func (s *Server) GenerateRoutes() http.Handler { config := cors.DefaultConfig() config.AllowWildcard = true @@ -1105,6 +1112,7 @@ func (s *Server) GenerateRoutes() http.Handler { r := gin.Default() r.Use( + CacheControlMiddleware(), cors.New(config), allowedHostsMiddleware(s.addr), )