mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-18 21:16:10 +05:00
add cache control
This commit is contained in:
@@ -82,11 +82,16 @@ func writeRoute(fname string, fmap map[string]string) {
|
|||||||
embedStr := `package template
|
embedStr := `package template
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/md5"
|
||||||
|
"fmt"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
func RouteWebPages(route *gin.RouterGroup) {
|
func RouteWebPages(route *gin.RouterGroup) {
|
||||||
route.GET("/", func(c *gin.Context) {
|
route.GET("/", func(c *gin.Context) {
|
||||||
|
etag := fmt.Sprintf("%x", md5.Sum(Indexhtml))
|
||||||
|
c.Header("Cache-Control", "public, max-age=31536000")
|
||||||
|
c.Header("ETag", etag)
|
||||||
c.Data(200, "text/html; charset=utf-8", Indexhtml)
|
c.Data(200, "text/html; charset=utf-8", Indexhtml)
|
||||||
})
|
})
|
||||||
`
|
`
|
||||||
@@ -108,6 +113,9 @@ func RouteWebPages(route *gin.RouterGroup) {
|
|||||||
}
|
}
|
||||||
embedStr += `
|
embedStr += `
|
||||||
route.GET("` + link + `", func(c *gin.Context) {
|
route.GET("` + link + `", func(c *gin.Context) {
|
||||||
|
etag := fmt.Sprintf("%x", md5.Sum(` + fmap[link] + `))
|
||||||
|
c.Header("Cache-Control", "public, max-age=31536000")
|
||||||
|
c.Header("ETag", etag)
|
||||||
c.Data(200, "` + fmime + `", ` + fmap[link] + `)
|
c.Data(200, "` + fmime + `", ` + fmap[link] + `)
|
||||||
})
|
})
|
||||||
`
|
`
|
||||||
|
|||||||
Reference in New Issue
Block a user