Added cache options and config.

This commit is contained in:
mikestefanello 2021-12-05 21:56:57 -05:00
parent bccb538d19
commit e499257686
3 changed files with 10 additions and 1 deletions

View file

@ -34,6 +34,11 @@ type Page struct {
}
Pager pager.Pager
CSRF string
Cache struct {
Enabled bool
MaxAge int
Tags []string
}
}
func NewPage(c echo.Context) Page {

View file

@ -32,7 +32,7 @@ func BuildRouter(c *container.Container) {
// Static files with proper cache control
// funcmap.File() should be used in templates to append a cache key to the URL in order to break cache
// after each server restart
c.Web.Group("", middleware.CacheControl(15552000)).
c.Web.Group("", middleware.CacheControl(c.Config.Cache.MaxAge.StaticFile)).
Static("/", StaticDir)
// Base controller