London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

Navigation [hide] [expand]
Area: Optimizely Search & Navigation
ARCHIVED This content is retired and no longer maintained. See the latest version here.

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.

Examples

The code below 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.

Last updated: Sep 21, 2015