Skip to content

Commit

Permalink
设置静态文件缓存header
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyiwy committed Jul 9, 2022
1 parent c7fa8b8 commit e0c9143
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func initRouter() *gin.Engine {

r.SetHTMLTemplate(template.Must(template.New("").ParseFS(tmpl, "templates/*.html")))
r.Any("/static/*filepath", func(c *gin.Context) {
c.Header("Cache-Control", "max-age=3153600")
staticServer := http.FileServer(http.FS(assets))
staticServer.ServeHTTP(c.Writer, c.Request)
})
Expand Down

0 comments on commit e0c9143

Please sign in to comment.