News for hackers. Stuff that matters.
Re:So you want to offer a public API … by MatthewPhillips on Wednesday July 25, 2012 @08:58AM (#4290674)
The server needs to respond with a Vary header which tells the user agent (the browser) how to identify what it should cache.

[1]https://developer.mozilla.org/en/HTTP/Content_negotiation

Re:So you want to offer a public API … by e98cuenc on Wednesday July 25, 2012 @12:39PM (#4291722)
The problem I have with Vary headers is that many reverse proxies will just not cache anything with a Vary header. The reason is that if they add the value of the header that "varies" to the key of the cache, now they have to cache under many different keys the same content.

Think of all the different "Accept" headers that clients can send you, each one of these will get an entry in your cache. And now add other headers that should also be in "Vary" like "Cookies", "Accept-Language", etc. and your cache will be virtually useless.

Re:So you want to offer a public API … by buddydvd on Wednesday July 25, 2012 @03:31PM (#4292601)
Interesting. Perhaps, instead of relying on "Vary: Accept" the server should respond with: "Vary: YourCustomHeader". The API client, on the other hand, will include "YourCustomHeader: SomeConstantValue" when making requests to the server. That way, the reverse proxy will only store up to two versions in its cache.
Re:So you want to offer a public API … by Gigablah on Thursday July 26, 2012 @09:17AM (#4295800)
Unfortunately, Chrome disregards the Vary header :(

http://code.google.com/p/chromium/issues/detail?id=94369

Re:So you want to offer a public API … by Gigablah on Wednesday July 25, 2012 @10:26AM (#4291067)
Ah, so I should set "Vary: Accept". Thanks, that was a great help.