Client Caching (Policy)

Client Caching (Policy)

This concern allows to instruct clients to cache responses generated by the server for some duration by adding the Expires HTTP header. The following example will cause the static website to be cached for one week:

var website = StaticWebsite.From(...)


If needed, a predicate can be passed to specify the content that should be cached more explicitly:

var policy = ClientCache.Policy()
                        .Predicate((req, resp) => resp.ContentType?.RawType != "text/html")); // do not cache HTML pages