I have a REST api developed with django-tastypie. I have a couple of resources that are quite heavy but are not mutable, so I would like the browser to cache them to avoid unnecesary requests.
I’ve set the HTTP Expire header to a date far two years in the future, this is what the browser gets:
HTTP/1.1 200 OK
Date: Wed, 16 May 2012 17:29:33 GMT
Server: Apache/2.2.14 (Ubuntu)
Vary: Cookie,Accept-Encoding,User-Agent
Expires: Tue, 06 May 2014 17:29:33 GMT
Cache-Control: no-cache, public
Content-Encoding: gzip
Access-Control-Allow-Origin: *
Content-Length: 1051
Keep-Alive: timeout=15, max=82
Connection: Keep-Alive
Content-Type: application/json; charset=utf-8
I’m using jQuery.ajax to issue the request. The expires header looks good, but the request is made each time I refresh the page.
This is your problem:
Cache-Control: no-cachefrom the spec: