I’m building a custom ContentFinder where I want to retrieve an IPublishedContent page based on the request path. In v13 (LTS), it was possible to do this without warnings using the following on IUmbracoContext:
var currentContent = umbracoContext.Content.GetByRoute(path, culture: culture);
However, in v16, this approach is no longer recommended, and you’re advised to use IPublishedContentCache.GetByRoute() instead. That seemed fine, so I switched to that method — but then I noticed that it’s now marked [Obsolete] without any clear explanation.
I then considered using IDocumentUrlService.GetDocumentKeyByRoute() to retrieve the node’s key, so that I could later fetch the content via IPublishedContentCache.GetByIdAsync().
Sounds good, right? That’s what I thought — until I realized that IDocumentUrlService.GetDocumentKeyByRoute() might internally use IContentService. That would mean it’s querying the database directly, not the cache, which is something I want to avoid in a ContentFinder, since that would immediately impact performance for every request.
So my question is:
Does IDocumentUrlService.GetDocumentKeyByRoute() use IPublishedContent (cached) or IContent (database) internally for its lookup?
If it uses IContent, that would not be acceptable for my use case, and I’d be interested in any alternatives that avoid database access and rely solely on the cache.
Regards,
Joppe