{"action":"opened","issue":{"url":"https://api.github.com/repos/mysociety/popit/issues/813","labels_url":"https://api.github.com/repos/mysociety/popit/issues/813/labels{/name}","comments_url":"https://api.github.com/repos/mysociety/popit/issues/813/comments","events_url":"https://api.github.com/repos/mysociety/popit/issues/813/events","html_url":"https://github.com/mysociety/popit/issues/813","id":65304805,"number":813,"title":"images from the image proxy aren't being cached","user":{"login":"mhl","id":7907,"avatar_url":"https://avatars.githubusercontent.com/u/7907?v=3","gravatar_id":"","url":"https://api.github.com/users/mhl","html_url":"https://github.com/mhl","followers_url":"https://api.github.com/users/mhl/followers","following_url":"https://api.github.com/users/mhl/following{/other_user}","gists_url":"https://api.github.com/users/mhl/gists{/gist_id}","starred_url":"https://api.github.com/users/mhl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhl/subscriptions","organizations_url":"https://api.github.com/users/mhl/orgs","repos_url":"https://api.github.com/users/mhl/repos","events_url":"https://api.github.com/users/mhl/events{/privacy}","received_events_url":"https://api.github.com/users/mhl/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-03-30T21:20:35Z","updated_at":"2015-03-30T21:20:35Z","closed_at":null,"body":"If you make a request to the image proxy, e.g.:\r\n\r\n```\r\ncurl -v -O https://yournextmp.popit.mysociety.org/image-proxy/http%3A%2F%2Fyournextmp.popit.mysociety.org%2Fpersons%2F4493%2Fimage%2F5481e8f6b150e238702c061b/0/64\r\n```\r\n\r\nAnd do it again shortly afterwards, the requests to the image proxy are all varnish misses:\r\n\r\n```\r\nx.x.x.x - - [30/Mar/2015:22:07:55 +0100] \"GET http://yournextmp.popit.mysociety.org/persons/4493/image/5481e8f6b150e238702c061b HTTP/1.1\" 302 116 \"-\" \"image-proxy/0.0.4\" yournextmp.popit.mysociety.org miss\r\nx.x.x.x - - [30/Mar/2015:22:07:55 +0100] \"GET http://yournextmp.popit.mysociety.org/persons/4493/image/5481e8f6b150e238702c061b HTTP/1.0\" 200 334049 \"-\" \"image-proxy/0.0.4\" yournextmp.popit.mysociety.org miss\r\nx.x.x.x - - [30/Mar/2015:22:07:52 +0100] \"GET http://yournextmp.popit.mysocito tety.org/image-proxy/http%3A%2F%2Fyournextmp.popit.mysociety.org%2Fpersons%2F4493%2Fimage%2F5481e8f6b150e238702c061b/0/64 HTTP/1.0\" 200 11627 \"-\" \"curl/7.35.0\" yournextmp.popit.mysociety.org miss\r\nx.x.x.x - - [30/Mar/2015:22:08:43 +0100] \"GET http://yournextmp.popit.mysociety.org/persons/4493/image/5481e8f6b150e238702c061b HTTP/1.1\" 302 116 \"-\" \"image-proxy/0.0.4\" yournextmp.popit.mysociety.org miss\r\nx.x.x.x - - [30/Mar/2015:22:08:43 +0100] \"GET http://yournextmp.popit.mysociety.org/persons/4493/image/5481e8f6b150e238702c061b HTTP/1.0\" 200 334049 \"-\" \"image-proxy/0.0.4\" yournextmp.popit.mysociety.org miss\r\nx.x.x.x - - [30/Mar/2015:22:08:41 +0100] \"GET http://yournextmp.popit.mysociety.org/image-proxy/http%3A%2F%2Fyournextmp.popit.mysociety.org%2Fpersons%2F4493%2Fimage%2F5481e8f6b150e238702c061b/0/64 HTTP/1.0\" 200 11627 \"-\" \"curl/7.35.0\" yournextmp.popit.mysociety.org miss\r\n```\r\n\r\nThe implications for this are pretty horrible for pluto: the image-proxy does no caching of resized images itself (as @chrismytton explained in IRC), it just sets a max-age via Cache-Control to 1 year, and relies on Varnish to cache the results - since these requests are all Varnish misses, I assume this means that each image is being resized anew on every request. (!)\r\n\r\npluto has been very loaded recently (responding particularly slowly on 2015-03-30) and I suspect that this may be a large part of the problem.\r\n\r\nOne issue may be that any request for an image from the image proxy sets a cookie for `.popit.mysociety.org`:\r\n\r\n```\r\nSet-Cookie: connect.sess=XXXXX; Domain=.popit.mysociety.org; Path=/; HttpOnly; Secure\r\n```\r\n\r\n... which I think comes from Express's cookieSession middleware.\r\n\r\nSo I guess this might be causing the cache misses? (However, I would have thought that would only the case if the server said `Vary: Cookie`, and in fact this response just has `Vary: X-HTTP-Method-Override`. Maybe our Varnish configuration doesn't cache any request with a non-empty Cookie header after the Google Analytics and other known cookies have been stripped?)"}}