mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

bskyweb: do not serve cache headers on non-2XX for static assets (#7469)

authored by

devin ivy and committed by
GitHub
ec9cafdb c84158fa

+13 -7
+13 -7
bskyweb/cmd/bskyweb/server.go
··· 214 214 e.GET("/iframe/youtube.html", echo.WrapHandler(staticHandler)) 215 215 e.GET("/static/*", echo.WrapHandler(http.StripPrefix("/static/", staticHandler)), func(next echo.HandlerFunc) echo.HandlerFunc { 216 216 return func(c echo.Context) error { 217 - path := c.Request().URL.Path 218 - maxAge := 1 * (60 * 60) // default is 1 hour 217 + c.Response().Before(func() { 218 + if c.Response().Status >= 300 { 219 + return 220 + } 219 221 220 - // all assets in /static/js, /static/css, /static/media are content-hashed and can be cached for a long time 221 - if strings.HasPrefix(path, "/static/js/") || strings.HasPrefix(path, "/static/css/") || strings.HasPrefix(path, "/static/media/") { 222 - maxAge = 365 * (60 * 60 * 24) // 1 year 223 - } 222 + path := c.Request().URL.Path 223 + maxAge := 1 * (60 * 60) // default is 1 hour 224 224 225 - c.Response().Header().Set("Cache-Control", fmt.Sprintf("public, max-age=%d", maxAge)) 225 + // all assets in /static/js, /static/css, /static/media are content-hashed and can be cached for a long time 226 + if strings.HasPrefix(path, "/static/js/") || strings.HasPrefix(path, "/static/css/") || strings.HasPrefix(path, "/static/media/") { 227 + maxAge = 365 * (60 * 60 * 24) // 1 year 228 + } 229 + 230 + c.Response().Header().Set("Cache-Control", fmt.Sprintf("public, max-age=%d", maxAge)) 231 + }) 226 232 return next(c) 227 233 } 228 234 })