protected virtual void ApplyCacheHeaders(HttpResponseMessage response, HttpRequestMessage request)
{
/*
cache-response-directive =
"public" ; Section 14.9.1
| "private" [ "=" <"> 1#field-name <"> ] ; Section 14.9.1
| "no-cache" [ "=" <"> 1#field-name <"> ]; Section 14.9.1
| "no-store" ; Section 14.9.2
| "no-transform" ; Section 14.9.5
| "must-revalidate" ; Section 14.9.4
| "proxy-revalidate" ; Section 14.9.4
| "max-age" "=" delta-seconds ; Section 14.9.3
| "s-maxage" "=" delta-seconds ; Section 14.9.3
| cache-extension ; Section 14.9.6
*/
response.Headers.CacheControl = new CacheControlHeaderValue
{
MaxAge = MaxAge > 0 ? TimeSpan.FromSeconds(MaxAge) : (TimeSpan?) null,
SharedMaxAge = SMaxAge > 0 ? TimeSpan.FromSeconds(SMaxAge) : (TimeSpan?)null,
MustRevalidate = MustRevalidate,
ProxyRevalidate = ProxyRevalidate,
Private = Private,
Public = Public,
NoStore = NoStore,
NoCache = NoCache,
NoTransform = NoTransform,
};
if (NoCache)
{
response.Headers.Add("Pragma", "no-cache");
}
}