Twitter images are not cachable


#1

I have an app which pulls in images uploaded to Twitter via the new photo update API. However images are not cached once loaded. Each request to an image returns a 200 OK header rather than a 304 Not Modified header.

Go to any image URL such as this one: http://p.twimg.com/Aa3AKYpCAAAlTI_.jpg

and check the developer console for network requests. If you reload the page it returns the file as 200 OK, which means the file is downloaded again rather than being returned from the user’s browser cache.

Can Twitter (or perhaps Photobucket) add 304 Not Modified to their headers for images so they can be cached please? Otherwise preloading images is not possible and displaying images in an app always requires a download, which is ugly, slow, and costs Twitter bandwidth!

Thank you,
Paul.


#2

Thanks for the report. Looks like this is fixed now:

$ curl --verbose http://p.twimg.com/Aa3AKYpCAAAlTI_.jpg > /dev/null

GET /Aa3AKYpCAAAlTI_.jpg HTTP/1.1
User-Agent: curl/7.21.0 (x86_64-apple-darwin10.4.0) libcurl/7.21.0 OpenSSL/0.9.8r zlib/1.2.5 libidn/1.19
Host: p.twimg.com
Accept: /

< HTTP/1.1 200 OK

< ETag: “95e34a-63e5-4ae6b215820c0”
< Content-Length: 25573
< Content-Type: image/jpeg
< Expires: Thu, 13 Oct 2011 18:43:41 GMT
< Cache-Control: max-age=0, no-cache, no-store
< Pragma: no-cache
< Date: Thu, 13 Oct 2011 18:43:41 GMT
< Connection: keep-alive

Then:

$ curl --verbose -H "If-None-Match: “95e34a-63e5-4ae6b215820c0"” http://p.twimg.com/Aa3AKYpCAAAlTI_.jpg > /dev/null

GET /Aa3AKYpCAAAlTI_.jpg HTTP/1.1
User-Agent: curl/7.21.0 (x86_64-apple-darwin10.4.0) libcurl/7.21.0 OpenSSL/0.9.8r zlib/1.2.5 libidn/1.19
Host: p.twimg.com
Accept: /
If-None-Match: “95e34a-63e5-4ae6b215820c0”

< HTTP/1.1 304 Not Modified


#3