I am working with a particularly expensive (in terms of query and also bandwidth), think of it as a catalog of items. However, the catalog also needs to be comletely accurate at all times, i.e. updates to the catalog need to be reflected in real-time so a fixed cache expiration period will not work.
The catalog is currently being requested by the client using JQuery 1.8.2 exactly like this:
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "http://myserver.com/somejsonquery.aspx",
data: {},
dataType: "json",
success: function ( ... ) { ... },
error: function ( ... ) { ... }
});
And the result is properly formatted JSON with "application/json" content type.
Since I maintain a reliable cache on the server side, I'd really like to implement If-Modified-Since semantics so that my server can return 304 when the cache is current (without incurring the DB or network hit), and only send the new catalog to the client if a reload occurred since the "If-Modified-Since" timestamp.
However, I am having trouble getting this to work (at least on IE). I tried setting the following and still couldn't get the client to send If-Modified-Since:
- set "cache: true" on the JSON request
- make the server return "Cache-control: private" HTTP header in the response
Anyone with any insight on this?
As a follow up, I also wonder if I set the Cache-control to "public" (i.e. cachable by proxy servers), would the cache consistency still be maintained through the proxies? i.e. will the proxy check back to my server every time a client requests that page. If I were to enable proxy caching, I need to be completely sure that the proxy will guarantee a consistent cache state.
I've been stuck on this for a while, so any help will be appreciated!
Thanks, - K.