-
Notifications
You must be signed in to change notification settings - Fork 8
CacheKeyStrategy
Joakim Skoog edited this page Jun 11, 2017
·
3 revisions
The second main part of Cashew is the interface ICacheKeyStrategy which is used to create cache keys from a HttpRequestMessage and a HttpResponseMessage.
The default implementation is called HttpStandardKeyStrategy which is a HTTP standard compliant strategy for creating cache keys. It also has support for the vary header!
There's an option to configure how query strings should be handled while creating cache keys. You can either choose to include it in the cache key or ignore it as shown below:
//Using CacheKeySetting.Standard will result in a different cache key each time the query string changes
var queryStringStrategy = new HttpStandardKeyStrategy(cache, CacheKeySetting.Standard);
//Using CacheKeySetting.IgnoreQueryString will result in the same key even if the query string changes.
var uriStrategy = new HttpStandardKeyStrategy(cache, CacheKeySetting.IgnoreQueryString);