From d64b0f81c998f925ff70dacd2bbbcd4361d6a152 Mon Sep 17 00:00:00 2001 From: Will Norris Date: Wed, 14 Jun 2017 20:04:41 -0400 Subject: [PATCH] return 304 from TransformingTransport If the caching headers in the request are valid, return a 304 response instead of doing the transformation. Ref #92 --- imageproxy.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/imageproxy.go b/imageproxy.go index a4ca19e..850fd32 100644 --- a/imageproxy.go +++ b/imageproxy.go @@ -294,6 +294,11 @@ func (t *TransformingTransport) RoundTrip(req *http.Request) (*http.Response, er return nil, err } + if should304(req, resp) { + // bare 304 response, full response will be used from cache + return &http.Response{StatusCode: http.StatusNotModified}, nil + } + defer resp.Body.Close() b, err := ioutil.ReadAll(resp.Body) if err != nil {