Loading...
Area: Episerver Search & Navigation
Applies to versions: 12 and higher
Other versions:

Query caching

Recommendations [hide]

This topic explains caching of search results in Episerver Search & Navigation (formerly Episerver Find), and how to set the time interval for how long search results are cached.

How it works

Query caching is useful for example to make search-based implementations more resilient. Search requests can be cached for a certain duration using the StaticallyCacheFor method, which accepts a timespan. No cache key is required, since the search request will generate one.

Example

The following code returns a previously-cached result or executes the query and caches the result for five minutes.

var result = client.Search<BlogPost>()
    .StaticallyCacheFor(TimeSpan.FromMinutes(5))
    .GetResult();

You can also cache results with a dependency (System.Web.Caching.Dependency) using an overload to the StaticallyCacheFor method.

Related topics

Do you find this information helpful? Please log in to provide feedback.

Last updated: Mar 05, 2019

Recommendations [hide]