core/corehttp: Handle Etag for caching

This commit is contained in:
Matt Bell 2015-01-28 03:42:07 -08:00 committed by Juan Batiz-Benet
parent fb986fd822
commit cea68afa2e

View File

@ -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)