mirror of
https://github.com/mentos1386/zdravko.git
synced 2024-11-22 07:43:33 +00:00
feat: add cache headers for static and index
This commit is contained in:
parent
e7b51aefc5
commit
509cf026fd
2 changed files with 8 additions and 0 deletions
|
@ -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"),
|
||||||
|
|
|
@ -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),
|
||||||
}))
|
}))
|
||||||
|
|
Loading…
Reference in a new issue