sitecore8 - How to update cache for a Sitecore Web Api output upon the index update -


i implementing sitecore 8 web api. exact, using serviceapicontroller in sitecore services infrastructre. wonder how can cache json output controller in such way gets updated if lucene index fetching data from, gets rebuilt?

i have not registered controller controller rendering because apparently don't need , works out-of-box. read json output ajax call through jquery , javascript code , html markup inside mvc view rendering. guess doesn't make sense setup cache on view rendering. isn't it?

what should do?

the best option use htmlcache , store data there. cache gets completed cleared on publish, make sense use it.

you can add entry cache using sethtml method:

var cache = sitecore.caching.cachemanager.gethtmlcache(sitecore.context.site); var json = cache.gethtml("mycachekey"); if (string.isnullorwhitespace(json)) {     var json = // build json output here     cache.sethtml("mycachekey", jsonvalue); } return json; 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -