all repos — honk @ dd75003f3b2098015ffc98bd8d6289142ac39e04

my fork of honk

introduce some variation to caching to stagger refresh
Ted Unangst tedu@tedunangst.com
Mon, 15 Apr 2019 20:52:24 -0400
commit

dd75003f3b2098015ffc98bd8d6289142ac39e04

parent

8f4ed81333e2e8c1ac2bcef39c0b61f1f6cd33f7

1 files changed, 9 insertions(+), 3 deletions(-)

jump to
M honk.gohonk.go

@@ -29,6 +29,7 @@ _ "image/jpeg"

_ "image/png" "io" "log" + notrand "math/rand" "net/http" "os" "sort"

@@ -902,10 +903,15 @@ }

http.Redirect(w, r, "/honkers", http.StatusSeeOther) } +func somedays() string { + secs := 432000 + notrand.Int63n(432000) + return fmt.Sprintf("%d", secs) +} + func avatate(w http.ResponseWriter, r *http.Request) { n := r.FormValue("a") a := avatar(n) - w.Header().Set("Cache-Control", "max-age=432000") + w.Header().Set("Cache-Control", "max-age="+somedays()) w.Write(a) }

@@ -922,7 +928,7 @@ }

} func serveemu(w http.ResponseWriter, r *http.Request) { xid := mux.Vars(r)["xid"] - w.Header().Set("Cache-Control", "max-age=432000") + w.Header().Set("Cache-Control", "max-age="+somedays()) http.ServeFile(w, r, "emus/"+xid) }

@@ -938,7 +944,7 @@ http.NotFound(w, r)

return } w.Header().Set("Content-Type", media) - w.Header().Set("Cache-Control", "max-age=432000") + w.Header().Set("Cache-Control", "max-age="+somedays()) w.Write(data) }