MCPcopy Index your code
hub / github.com/authorizerdev/authorizer / spaBuildCacheMiddleware

Function spaBuildCacheMiddleware

internal/server/http_routes.go:21–31  ·  view source on GitHub ↗

spaBuildCacheMiddleware sets cache headers for SPA build assets: - "index.js" / "main.css" (unhashed entry points the shell HTML loads by name) → no-cache, so browsers always pick up new chunk references after a deploy. - everything else (content-hashed chunks, immutable assets) → long-lived immutab

()

Source from the content-addressed store, hash-verified

19// - everything else (content-hashed chunks, immutable assets) → long-lived
20// immutable cache, since a content change produces a new filename.
21func spaBuildCacheMiddleware() gin.HandlerFunc {
22 return func(c *gin.Context) {
23 base := path.Base(c.Request.URL.Path)
24 if base == "index.js" || base == "main.css" {
25 c.Header("Cache-Control", "no-cache, must-revalidate")
26 } else {
27 c.Header("Cache-Control", "public, max-age=31536000, immutable")
28 }
29 c.Next()
30 }
31}
32
33// NewRouter creates new gin router
34func (s *server) NewRouter() *gin.Engine {

Callers 1

NewRouterMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected