File tree Expand file tree Collapse file tree 1 file changed +4
-7
lines changed
Expand file tree Collapse file tree 1 file changed +4
-7
lines changed Original file line number Diff line number Diff line change @@ -3,22 +3,19 @@ package common
33import (
44 "github.com/gin-gonic/gin"
55 "github.com/we7coreteam/w7-rangine-go/v2/src/http/middleware"
6- http2 "net/http"
76 "strconv"
87 "strings"
9- "time"
108)
119
1210type CacheMiddleware struct {
1311 middleware.Abstract
1412}
1513
1614func (self CacheMiddleware ) Process (http * gin.Context ) {
17- if strings .HasPrefix (http .Request .URL .Path , "/dpanel/static" ) {
18- defaultMaxAge := 604800
19- http .Writer .Header ().Add ("Cache-Control" , "public, max-age=" + strconv .Itoa (defaultMaxAge ))
20- http .Writer .Header ().Add ("Expires" , time .Now ().Add (time .Duration (defaultMaxAge )* time .Second ).UTC ().Format (http2 .TimeFormat ))
21- http .Writer .WriteHeader (304 )
15+ url := http .Request .URL .Path
16+ if strings .HasPrefix (url , "/dpanel/static" ) || strings .HasPrefix (url , "/favicon.ico" ) {
17+ defaultMaxAge := 3600
18+ http .Header ("Cache-Control" , "public, max-age=" + strconv .Itoa (defaultMaxAge ))
2219 }
2320 http .Next ()
2421 return
You can’t perform that action at this time.
0 commit comments