From ab7c4e72c6129b32b29afc84427c79a320964fc9 Mon Sep 17 00:00:00 2001 From: gadotroee <55343099+gadotroee@users.noreply.github.com> Date: Tue, 31 Aug 2021 15:27:13 +0300 Subject: [PATCH] no message (#253) --- agent/main.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/agent/main.go b/agent/main.go index 8f0ffd4d6..8aff329c3 100644 --- a/agent/main.go +++ b/agent/main.go @@ -107,6 +107,7 @@ func hostApi(socketHarOutputChannel chan<- *tap.OutputChannelItem) { SocketHarOutChannel: socketHarOutputChannel, } + app.Use(DisableRootStaticCache()) app.Use(static.ServeRoot("/", "./site")) app.Use(CORSMiddleware()) // This has to be called after the static middleware, does not work if its called before @@ -119,6 +120,17 @@ func hostApi(socketHarOutputChannel chan<- *tap.OutputChannelItem) { utils.StartServer(app) } +func DisableRootStaticCache() gin.HandlerFunc { + return func(c *gin.Context) { + if c.Request.RequestURI == "/" { + // Disable cache only for the main static route + c.Writer.Header().Set("Cache-Control", "no-store") + } + + c.Next() + } +} + func CORSMiddleware() gin.HandlerFunc { return func(c *gin.Context) { c.Writer.Header().Set("Access-Control-Allow-Origin", "*")