diff --git a/imageproxy.go b/imageproxy.go index a52ad6f..dbb8a2d 100644 --- a/imageproxy.go +++ b/imageproxy.go @@ -275,7 +275,7 @@ func should304(req *http.Request, resp *http.Response) bool { if err != nil { return false } - if lastModified.Before(ifModSince) { + if lastModified.Before(ifModSince) || lastModified.Equal(ifModSince) { return true } diff --git a/imageproxy_test.go b/imageproxy_test.go index 6a242c7..aa5878a 100644 --- a/imageproxy_test.go +++ b/imageproxy_test.go @@ -223,11 +223,16 @@ func TestShould304(t *testing.T) { "HTTP/1.1 200 OK\nEtag: \"v\"\n\n", true, }, - { // last-modified match + { // last-modified before "GET / HTTP/1.1\nIf-Modified-Since: Sun, 02 Jan 2000 00:00:00 GMT\n\n", "HTTP/1.1 200 OK\nLast-Modified: Sat, 01 Jan 2000 00:00:00 GMT\n\n", true, }, + { // last-modified match + "GET / HTTP/1.1\nIf-Modified-Since: Sat, 01 Jan 2000 00:00:00 GMT\n\n", + "HTTP/1.1 200 OK\nLast-Modified: Sat, 01 Jan 2000 00:00:00 GMT\n\n", + true, + }, // mismatches {