disable some more cache control in debug mode
Ted Unangst tedu@tedunangst.com
Wed, 04 Dec 2019 00:44:45 -0500
4 files changed,
20 insertions(+),
14 deletions(-)
M
skulduggery.go
→
skulduggery.go
@@ -21,7 +21,6 @@
"github.com/mattn/go-runewidth" ) - var skinTones = "\U0001F3FB\U0001F3FC\U0001F3FD\U0001F3FE\U0001F3FF" var re_moredumb = regexp.MustCompile("[\U0001f44f\U0001f6a8\U000026a0][" + skinTones + "\ufe0f]*")
M
web.go
→
web.go
@@ -48,6 +48,8 @@
var userSep = "u" var honkSep = "h" +var debugMode = false + func getuserstyle(u *login.UserInfo) template.CSS { if u == nil { return ""@@ -223,8 +225,10 @@ if honk.Date.After(modtime) {
modtime = honk.Date } } - w.Header().Set("Cache-Control", "max-age=300") - w.Header().Set("Last-Modified", modtime.Format(http.TimeFormat)) + if !debugMode { + w.Header().Set("Cache-Control", "max-age=300") + w.Header().Set("Last-Modified", modtime.Format(http.TimeFormat)) + } err := feed.Write(w) if err != nil {@@ -874,7 +878,7 @@ }
sort.Slice(onts, func(i, j int) bool { return onts[i].Name < onts[j].Name }) - if u == nil { + if u == nil && !debugMode { w.Header().Set("Cache-Control", "max-age=300") } templinfo := getInfo(r)@@ -1093,7 +1097,7 @@ } else {
templinfo["TopHID"] = 0 } } - if u == nil { + if u == nil && !debugMode { w.Header().Set("Cache-Control", "max-age=60") } err := readviews.Execute(w, "honkpage.html", templinfo)@@ -1991,7 +1995,9 @@ w.Write(a)
} func serveasset(w http.ResponseWriter, r *http.Request) { - //w.Header().Set("Cache-Control", "max-age=7776000") + if !debugMode { + w.Header().Set("Cache-Control", "max-age=7776000") + } dir := viewDir if r.URL.Path == "/local.css" { dir = dataDir@@ -2000,7 +2006,9 @@ http.ServeFile(w, r, dir+"/views"+r.URL.Path)
} func servehelp(w http.ResponseWriter, r *http.Request) { name := mux.Vars(r)["name"] - //w.Header().Set("Cache-Control", "max-age=3600") + if !debugMode { + w.Header().Set("Cache-Control", "max-age=3600") + } http.ServeFile(w, r, viewDir+"/docs/"+name) } func servehtml(w http.ResponseWriter, r *http.Request) {@@ -2012,7 +2020,7 @@ templinfo["HonkVersion"] = softwareVersion
if r.URL.Path == "/about" { templinfo["Sensors"] = getSensors() } - if u == nil { + if u == nil && !debugMode { w.Header().Set("Cache-Control", "max-age=60") } err := readviews.Execute(w, r.URL.Path[1:]+".html", templinfo)@@ -2229,9 +2237,8 @@ go enditall()
go redeliverator() go tracker() - debug := false - getconfig("debug", &debug) - readviews = templates.Load(debug, + getconfig("debug", &debugMode) + readviews = templates.Load(debugMode, viewDir+"/views/honkpage.html", viewDir+"/views/honkfrags.html", viewDir+"/views/honkers.html",@@ -2249,7 +2256,7 @@ viewDir+"/views/header.html",
viewDir+"/views/onts.html", viewDir+"/views/honkpage.js", ) - if !debug { + if !debugMode { assets := []string{viewDir + "/views/style.css", dataDir + "/views/local.css", viewDir + "/views/honkpage.js"} for _, s := range assets { savedassetparams[s] = getassetparam(s)