mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 10:27:46 +08:00
core/corehttp: Handle Etag for caching
This commit is contained in:
parent
fb986fd822
commit
cea68afa2e
@ -129,8 +129,14 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
etag := path.Base(p)
|
||||
if r.Header.Get("If-None-Match") == etag {
|
||||
w.WriteHeader(http.StatusNotModified)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Etag", etag)
|
||||
w.Header().Set("X-IPFS-Path", p)
|
||||
w.Header().Set("Etag", path.Base(p))
|
||||
w.Header().Set("Cache-Control", "public, max-age=29030400")
|
||||
|
||||
dr, err := i.NewDagReader(nd)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user