Skip to content

Commit e104a26

Browse files
committed
update cache
1 parent cf09381 commit e104a26

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

route/static_route.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package route
22

33
import (
44
"os"
5+
"path"
56

67
"github.com/IceWhaleTech/CasaOS-Gateway/service"
78
"github.com/gin-contrib/gzip"
@@ -33,9 +34,14 @@ func (s *StaticRoute) GetRoute() *gin.Engine {
3334
r.Use(gzip.Gzip(gzip.DefaultCompression))
3435

3536
r.Use(func(ctx *gin.Context) {
36-
if _, ok := RouteCache[ctx.Request.URL.Path]; !ok {
37-
ctx.Writer.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate,proxy-revalidate, max-age=0")
38-
RouteCache[ctx.Request.URL.Path] = ctx.Request.URL.Path
37+
// Extract the file name from the path
38+
_, file := path.Split(ctx.Request.URL.Path)
39+
// If the file name contains a dot, it's likely a file
40+
if path.Ext(file) == "" {
41+
if _, ok := RouteCache[ctx.Request.URL.Path]; !ok {
42+
ctx.Writer.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate,proxy-revalidate, max-age=0")
43+
RouteCache[ctx.Request.URL.Path] = ctx.Request.URL.Path
44+
}
3945
}
4046
ctx.Next()
4147
})

0 commit comments

Comments
 (0)