0

I have a jstree that loads it's data from a DB through a WCF service using JSON.

I managed to get jstree's rename context menu item to "work", meaning: I bound an ajax call to the jstree rename event, so when the user renames a node, it tells a WCF method to update the database (to "save" the new name).

Problem: If I go to another page and then come back later, the node has reverted to the old name!

It looks like there is some kind of caching going on, either in jstree or the browser, or WCF, and the tree isn't being refreshed somehow.

The data is coming from a database via a WCF service method over JSON. When you first visit the page, the data is loaded. But when you come back to the page, it isn't: the breakpoint in the server-side load method is never hit. It seems likely to me that either:

  • jstree has cached the data and doesn't try to load it again (but why doesn't it stay renamed?)

OR

  • jstree asks the service, but WCF just gives the same data again from a cache rather than actually running the service method.

OR

  • The browser is caching the request and giving the same result back to jstree without calling the WCF method.

Any ideas? How can I check this?

Zain Shaikh
  • 6,013
  • 6
  • 41
  • 66
MGOwen
  • 6,562
  • 13
  • 58
  • 67

1 Answers1

1

Because you not sure whether you have caching problem I suggest you to include in the WCF method which you call from jstree the following line (for example as the first line in the method body):

WebOperationContext.Current.OutgoingResponse.Headers.Set (
    HttpResponseHeader.CacheControl,
    "max-age=0");

It will follow to cache revalidation. So the web browser or a proxy, which probably are also used, will not not use the cached vesrsion of data without revalidation (calling the same WCF method) on the server. You can also consider to use other cache-control options.

Oleg
  • 220,925
  • 34
  • 403
  • 798