diff --git a/okserver.go b/okserver.go index ab6854066994dc15640abbd6e1ba5a6f6bc43664..3de44c03e81676ff83a0f9a3839ebc88496d374c 100644 --- a/okserver.go +++ b/okserver.go @@ -17,12 +17,18 @@ func main() { // Create a very simple HTTP server with two endpoints: one // that just replies "OK", and one that dumps the incoming // request back to the client. + // + // The OK handler answers with a cachable response, while the + // dynamic one sets cache-busting headers. http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { switch r.URL.Path { case "/echo": w.Header().Set("Content-Type", "text/plain") + w.Header().Set("Expires", "-1") + w.Header().Set("Cache-Control", "no-store") r.Write(w) case "/", "/health": + w.Header().Set("Cache-Control", "max-age=86400") io.WriteString(w, "OK\n") default: http.NotFound(w, r)