core/corehttp: Handle Etag for caching
Matt Bell committed
Jan 28, 2015 at 03:42 UTC
cea68afa2e8d78fd64ac476eeedc3e7b2ffc4d9d
1 file changed
+7
-1
core/corehttp/gateway_handler.go
+7
-1
@@ -129,8 +129,14 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
129
return
130
}
131
132
+ etag := path.Base(p)
133
+ if r.Header.Get("If-None-Match") == etag {
134
+ w.WriteHeader(http.StatusNotModified)
135
+ return
136
+ }
137
+
138
+ w.Header().Set("Etag", etag)
139
w.Header().Set("X-IPFS-Path", p)
133
- w.Header().Set("Etag", path.Base(p))
140
w.Header().Set("Cache-Control", "public, max-age=29030400")
141
142
dr, err := i.NewDagReader(nd)