Skip to content

Commit

Permalink
Cache assets
Browse files Browse the repository at this point in the history
  • Loading branch information
thomiceli committed Sep 8, 2024
1 parent de6578d commit d4e4ae0
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/web/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,9 @@ func NewServer(isDev bool, sessionsPath string) *Server {
customFs := os.DirFS(filepath.Join(config.GetHomeDir(), "custom"))
e.GET("/assets/*", func(ctx echo.Context) error {
if _, err := public.Files.Open(path.Join("assets", ctx.Param("*"))); !dev && err == nil {
ctx.Response().Header().Set("Cache-Control", "public, max-age=31536000")
ctx.Response().Header().Set("Expires", time.Now().AddDate(1, 0, 0).Format(http.TimeFormat))

return echo.WrapHandler(http.FileServer(http.FS(public.Files)))(ctx)
}

Expand Down

0 comments on commit d4e4ae0

Please sign in to comment.