Quantcast
Channel: Developing Apps for SharePoint 2013 forum
Viewing all articles
Browse latest Browse all 8089

Should we cache the SharePoint ClientContext Object

$
0
0

We have a SharePoint 2013 app and we found out that most of time is consumed at querying SharePoint by using CSOM API via ClientContext.ExecuteQuery. It seems that the first call is always expensive and then subsequent calls on ExecuteQuery is reasonably fast. We know that we should call ExecuteQuery as few times as possible by grouping couple queries into one Execute. However it might not give us the sufficient performance gain and it might not be all possible to group the calls on ExecuteQuery all the time, we are also thinking about caching the ClientContext for each user. Obviously we would need code to clean up the ClientContext as well since we could not cache it indefinitely.

However from this post, SharePoint 2010 Client Object Model, it says the following:

It is not recommended to cache the ClientContext since it does hold resources   and may cause degradation of your application. Best to follow the database connection model; open late, use and close.

With that, I am not sure whether we should cache or not. I didn't find anything by searching over the internet other than this stackoverflow post where the author was able to cache ClientContext at local machine and is looking to use the cache at another machine.

Your insight would be greatly appreciated here.


Viewing all articles
Browse latest Browse all 8089

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>