However, I have been informed that this value is not cached and thus has slower performance than working with IPublishedContent objects. Unfortunately, it appears that IPublishedContent objects are not provided by any method of ApplicationContext.Current.Services.ContentService. There is a ApplicationContext.Current.Services.ContentService.GetPublishedVersion(nodeId) that I could use, but that still returns an IContent object, so I have no way to determine if it will return the cached version of the object (and I have no time for performance testing this object).
How do I obtain the IPublishedContent or equivalently cached version of the object from my Web API (GET) method?
How do I get the IPublishedContent instead of IContent? From ApplicationContext?
Hi,
I am trying to avoid being late on a deadline. To get the IContent objects by ID from my web api method, I would use code like this:
However, I have been informed that this value is not cached and thus has slower performance than working with IPublishedContent objects. Unfortunately, it appears that IPublishedContent objects are not provided by any method of ApplicationContext.Current.Services.ContentService. There is a ApplicationContext.Current.Services.ContentService.GetPublishedVersion(nodeId) that I could use, but that still returns an IContent object, so I have no way to determine if it will return the cached version of the object (and I have no time for performance testing this object).
How do I obtain the IPublishedContent or equivalently cached version of the object from my Web API (GET) method?
Thanks in advance.
You need to use UmbracoContext.Current.ContentCache instead of ApplicationContext.
ContentCache returns IPublishedContent instead of the ContentService in ApplicationContext.Current.Services.
HTH
Benjamin
Hi Benjamin,
How can i get the ContentCache object using DI ?
Thanks, Vivek
Hi Devin,
You can create an instance of the UmbracoHelper class using the current Umbraco Context. For example:
Thanks, Dan.
is working on a reply...