ResponseCaching checks values like no-store and no-cache when deciding whether a response should be cached.
|
var responseCacheControlHeader = context.HttpContext.Response.Headers.CacheControl; |
|
|
|
// Only cache pages explicitly marked with public |
|
if (!HeaderUtilities.ContainsCacheDirective(responseCacheControlHeader, CacheControlHeaderValue.PublicString)) |
|
{ |
|
context.Logger.ResponseWithoutPublicNotCacheable(); |
|
return false; |
|
} |
|
|
|
// Check response no-store |
|
if (HeaderUtilities.ContainsCacheDirective(responseCacheControlHeader, CacheControlHeaderValue.NoStoreString)) |
|
{ |
|
context.Logger.ResponseWithNoStoreNotCacheable(); |
|
return false; |
|
} |
|
|
|
// Check no-cache |
|
if (HeaderUtilities.ContainsCacheDirective(responseCacheControlHeader, CacheControlHeaderValue.NoCacheString)) |
|
{ |
|
context.Logger.ResponseWithNoCacheNotCacheable(); |
|
return false; |
|
} |
HttpSys currently relies on public, we should update the checks here to avoid any mistakes that could come from user error adding both public and a non-caching primitive.
|
// We require 'public' and 's-max-age' or 'max-age' or the Expires header. |
ResponseCaching checks values like
no-storeandno-cachewhen deciding whether a response should be cached.aspnetcore/src/Middleware/ResponseCaching/src/ResponseCachingPolicyProvider.cs
Lines 68 to 89 in 7eef825
HttpSys currently relies on
public, we should update the checks here to avoid any mistakes that could come from user error adding bothpublicand a non-caching primitive.aspnetcore/src/Servers/HttpSys/src/RequestProcessing/RequestContext.FeatureCollection.cs
Line 727 in 7eef825