feat: add cache headers for static and index

This commit is contained in:
Tine 2024-04-28 16:23:41 +02:00
parent e7b51aefc5
commit 509cf026fd
Signed by: mentos1386
SSH key fingerprint: SHA256:MNtTsLbihYaWF8j1fkOHfkKNlnN1JQfxEU/rBU8nCGw
2 changed files with 8 additions and 0 deletions

View file

@ -165,6 +165,8 @@ func (h *BaseHandler) Index(c echo.Context) error {
} }
} }
c.Response().Header().Set("Cache-Control", "max-age=10")
return c.Render(http.StatusOK, "index.tmpl", &IndexData{ return c.Render(http.StatusOK, "index.tmpl", &IndexData{
Base: &components.Base{ Base: &components.Base{
NavbarActive: GetPageByTitle(Pages, "Status"), NavbarActive: GetPageByTitle(Pages, "Status"),

View file

@ -35,6 +35,12 @@ func Routes(
// Server static files // Server static files
stat := e.Group("/static") stat := e.Group("/static")
stat.Use(func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
c.Response().Header().Set("Cache-Control", "public, max-age=60")
return next(c)
}
})
stat.Use(middleware.StaticWithConfig(middleware.StaticConfig{ stat.Use(middleware.StaticWithConfig(middleware.StaticConfig{
Filesystem: http.FS(static.Static), Filesystem: http.FS(static.Static),
})) }))