write no cache header

This commit is contained in:
gempir 2022-09-23 20:08:04 +02:00
parent 20c9986a0a
commit 389b15f9cf

View file

@ -234,6 +234,8 @@ func (s *Server) routeLogs(w http.ResponseWriter, r *http.Request) bool {
if (request.time.year != "" && request.time.month != "") && (request.time.year < currentYear || (request.time.year == currentYear && request.time.month < currentMonth)) {
writeCacheControl(w, r, time.Hour*8760)
} else {
writeCacheControlNoCache(w, r)
}
if request.responseType == responseTypeJSON {
@ -329,6 +331,10 @@ func writeCacheControl(w http.ResponseWriter, r *http.Request, cacheDuration tim
w.Header().Set("Cache-Control", fmt.Sprintf("public, max-age=%.0f", cacheDuration.Seconds()))
}
func writeCacheControlNoCache(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Cache-Control", "no-cache")
}
func writeRaw(cLog *chatLog, code int, w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
w.WriteHeader(code)