Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update cache-control header #2910

Merged
merged 1 commit into from
Aug 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/jetstream/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,8 @@ func (p *portalProxy) registerRoutes(e *echo.Echo, addSetupMiddleware *setupMidd
pp = e.Group("")
}

pp.Use(p.setSecureCacheContentMiddleware)

// Add middleware to block requests if unconfigured
if addSetupMiddleware.addSetup {
go p.SetupPoller(addSetupMiddleware)
Expand Down Expand Up @@ -732,6 +734,7 @@ func (p *portalProxy) registerRoutes(e *echo.Echo, addSetupMiddleware *setupMidd

// Serve up static resources
if err == nil {
e.Use(p.setStaticCacheContentMiddleware)
log.Debug("Add URL Check Middleware")
e.Use(p.urlCheckMiddleware)
e.Use(middleware.Gzip())
Expand Down
15 changes: 15 additions & 0 deletions src/jetstream/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,21 @@ func (p *portalProxy) urlCheckMiddleware(h echo.HandlerFunc) echo.HandlerFunc {
}
}

func (p *portalProxy) setStaticCacheContentMiddleware(h echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
log.Debug("setStaticContentHeadersMiddleware")
c.Response().Header().Set("cache-control", "no-cache")
return h(c)
}
}

func (p *portalProxy) setSecureCacheContentMiddleware(h echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
c.Response().Header().Set("cache-control", "no-store")
return h(c)
}
}

func (p *portalProxy) adminMiddleware(h echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
// if user is an admin, passthrough request
Expand Down