all repos — honk @ 04de37eac2655658ecfcb6887905c3688deecec3

my fork of honk

disable some more cache control in debug mode
Ted Unangst tedu@tedunangst.com
Wed, 04 Dec 2019 00:44:45 -0500
commit

04de37eac2655658ecfcb6887905c3688deecec3

parent

89a7cc9e19ea2d907a904b013e0d1cd59c2c6be3

4 files changed, 20 insertions(+), 14 deletions(-)

jump to
M hfcs.gohfcs.go

@@ -44,7 +44,7 @@ Rewrite string `json:",omitempty"`

re_rewrite *regexp.Regexp Replace string `json:",omitempty"` Expiration time.Time - Notes string + Notes string } type filtType uint
M honk.gohonk.go

@@ -179,7 +179,7 @@ XID string

Handle string Flavor string Combos []string - Meta HonkerMeta + Meta HonkerMeta } type HonkerMeta struct {
M skulduggery.goskulduggery.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.goweb.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)