Skip to content

Commit

Permalink
Fix cache in static uhandlers
Browse files Browse the repository at this point in the history
  • Loading branch information
zachhuff386 committed May 14, 2020
1 parent d20e1de commit 8a5c46d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions uhandlers/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/pritunl/pritunl-zero/utils"
)

func staticPath(c *gin.Context, pth string) {
func staticPath(c *gin.Context, pth string, cache bool) {
pth = config.StaticRoot + pth

file, ok := store.Files[pth]
Expand All @@ -20,7 +20,7 @@ func staticPath(c *gin.Context, pth string) {
return
}

if constants.StaticCache {
if constants.StaticCache && cache {
c.Writer.Header().Add("Cache-Control", "public, max-age=86400")
c.Writer.Header().Add("ETag", file.Hash)
} else {
Expand All @@ -45,19 +45,19 @@ func staticIndexGet(c *gin.Context) {
return
}

staticPath(c, "/uindex.html")
staticPath(c, "/uindex.html", false)
}

func staticLoginGet(c *gin.Context) {
staticPath(c, "/login.html")
staticPath(c, "/login.html", false)
}

func staticLogoGet(c *gin.Context) {
staticPath(c, "/logo.png")
staticPath(c, "/logo.png", true)
}

func staticGet(c *gin.Context) {
staticPath(c, "/static"+c.Params.ByName("path"))
staticPath(c, "/static"+c.Params.ByName("path"), true)
}

func staticTestingGet(c *gin.Context) {
Expand Down

0 comments on commit 8a5c46d

Please sign in to comment.