This can be expensive hence it is suggested to either your ViewModels implementing ICacheResource interface or implement ITimedETagExtractor - plenty of examples in the samples. If not, it will resort to serialising the ViewModel to JSON and use its hash as ETag. By default, it checks to see if the ViewModel has implemented ICacheResource, if so it enquires the TimedETag directly. ITimedETagExtractor: A CacheCow interface responsible for extracting TimedETag from view models sent back by the API.It is recommended to construct it with an ETag (due to low precision of DateTime in HTTP Spec's Last-Modified header). TimedETag: A CacheCow construct that combines Last-Modifed and ETag (can have either of them but not both) and represents a version of the resource and implemented as TimedEntityTagHeaderValue.If you have a high-precision Last-Modified date, it is better to turn it to ETag by binarising the date ( example). ETag header: ETag or EntityTag is an opaque string that identifies a version of resource (not representation).Last-Modified header: Since its precision is at seconds, its use is not recommended for valiation and instead, it is recommended to use ETag.It is crucial to note that the client normally does not eject the cached representation right after the expiry - the client can carry on using the cached representation provided it checks with the server if the representation is still valid (see Consistency below). Expiry: Expiry of a cached representation on the client is defined by the directives sent by the server.CacheCow sets both to support both HTTP 1.0 and 1.1. Cache-Control header provides richer semantic and supersedes it. Expires header: Defines expiry of a resource in absolute time.CacheCow has ICacheDirectiveProvider interface responsible for controlling these headers. These headers include Cache-Control, Vary, ETag and in HTTP 1.0 would include Expires, Last-Modified and Pragma (for the purpose of this article, we include ETag and Last-Modified as part of directives although purely speaking they are not). Cache directives: These are various cache-related headers that the server provides to guide the client on how best cache and validate the resources.CacheCow itself is responsible for storing representations separately. There are choice of storages, at this point InMemory and Redis are available. ICacheStore: CacheCow interface responsible for storing cacheable representation on the client.Despite the common notion, the representations get cached on the client (not server) and the server is responsible for providing cache directives and validate conditional requests on resources. HTTP Caching: Caching as described in HTTP 1.1 Specification (RFC 7230 or 2616).Headers by which representations will vary is defined by the Vary header from the server. Also the same resource could have two representations in Chinese or Spanish. For example /api/car/1 is a resource and it might have two representations as JSON or XML. Representation: A particular embodiment of a resource according to its format, language, etc.Resource: A RESTful resource - generally identified by its URI.CacheCow.Server: Server constructs for HTTP Caching when serving HTTP APIs in ASP.NET Web API or MVC Core.CacheCow.Client: Client constructs for HTTP Caching when making HTTP calls with.If you get bored reading this ?, jump straight to Getting Started sections or simply browse and run a couple of samples.
NET.FRAMEWORK 4.5.2 FOR LOW SPEC EXPERIENCE FREE
It is useful to start with concepts but feel free to use it as a reference. CacheCow.Client now copies any headers starting with x-cachecow it receives from the server to the response it delivers to your HttpClient.Renaming CacheCow client header from "x-cachecow" to "x-cachecow-client".ICacheStore implementations optionally supported a cache quota management interface which is no longer supported.Currently only Redis, SQL and InMemory are supported although I accept PR if you would like to add your storage. Many cache storages no longer maintained and available including: MongoDb, Memcached, File and Elasticsearch.
NET.FRAMEWORK 4.5.2 FOR LOW SPEC EXPERIENCE CODE
CacheCow.Client has some changes which may or may not break your code (depending whether you had used. Hence if you have used CacheCow.Server in the past and you would like to migrate, read the guide on migration further down. There are quite a few changes in the server-side implementation of CacheCow due to shortcomings of previous approach while the client-side mostly remained the same.