Hide menu Last updated: Oct 31 2016
Area: Episerver Find Applies to versions: 12 and higher
Other versions:

Caching

This topic explains the caching of search results, and how to set the time interval for how long the request is cached.

How it works

Search requests can be cached for a certain duration using the StaticallyCacheFor method, which accepts a timespan. No cache key is required, because the search request generates 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.

Comments