From 85d2be2e8c002f1207f39ab168ba2668511a9e33 Mon Sep 17 00:00:00 2001 From: Livio Amstutz Date: Fri, 20 Nov 2020 08:47:28 +0100 Subject: [PATCH] fix: handle short cache for console correctly (#993) --- internal/ui/console/console.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/internal/ui/console/console.go b/internal/ui/console/console.go index d1b415ac7a..9bfca32b1d 100644 --- a/internal/ui/console/console.go +++ b/internal/ui/console/console.go @@ -32,7 +32,8 @@ const ( ) var ( - paths = []string{ + shortCacheFiles = []string{ + "/", "/index.html", "/manifest.webmanifest", "/ngsw.json", @@ -91,14 +92,14 @@ func csp(zitadelDomain string) *middleware.CSP { func AssetsCacheInterceptorIgnoreManifest(shortMaxAge, shortSharedMaxAge, longMaxAge, longSharedMaxAge time.Duration) func(http.Handler) http.Handler { return func(handler http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - for _, path := range paths { - if r.URL.Path == path { + for _, file := range shortCacheFiles { + if r.URL.Path == file { middleware.AssetsCacheInterceptor(shortMaxAge, shortSharedMaxAge, handler).ServeHTTP(w, r) return } - middleware.AssetsCacheInterceptor(longMaxAge, longSharedMaxAge, handler).ServeHTTP(w, r) - return } + middleware.AssetsCacheInterceptor(longMaxAge, longSharedMaxAge, handler).ServeHTTP(w, r) + return }) } }