This content is archived. See latest version here

Last updated: Nov 16 2015

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.

C#
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.


Do you have feedback on this documentation? Send an email to documentation@episerver.com. For development-related questions and discussions, refer to our Forums on https://world.episerver.com/forum/