Skip to content

Commit abd8271

Browse files
committed
add cache-control header in api response
1 parent 387e37c commit abd8271

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

src/fs/service.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ func directory(fi os.FileInfo, js string, w http.ResponseWriter, request *http.R
165165
w.Header().Set("Content-Length", strconv.FormatInt(size, 10))
166166
w.Header().Set("Last-Modified", fi.ModTime().UTC().Format(http.TimeFormat))
167167
w.Header().Set("Content-Type", "application/json")
168+
w.Header().Set("Cache-Control", "max-age=0, private, must-revalidate")
168169
w.WriteHeader(http.StatusOK)
169170
w.Write(json)
170171
status = 200
@@ -266,6 +267,7 @@ func (service *MercuryFsService) serve_file(writer http.ResponseWriter, request
266267
} else {
267268
writer.Header().Set("Last-Modified", mtime)
268269
writer.Header().Set("ETag", etag)
270+
writer.Header().Set("Cache-Control", "max-age=0, private, must-revalidate")
269271
debug(4, "Etag sent: %s", etag)
270272
http.ServeContent(writer, request, full_path, fi.ModTime(), osFile)
271273
log("\"GET %s\" %d %d \"%s\"", query, 200, fi.Size(), ua)

0 commit comments

Comments
 (0)