public static CacheFreshnessStatus OnValidateFreshness(HttpRequestCacheValidator ctx)
{
// This will figure out ctx.CacheAge and ctx.CacheMaxAge memebers
CacheFreshnessStatus result = Common.ComputeFreshness(ctx);
/*
We note one exception to this rule: since some applications have
traditionally used GETs and HEADs with query URLs (those containing a
"?" in the rel_path part) to perform operations with significant side
effects, caches MUST NOT treat responses to such URIs as fresh unless
the server provides an explicit expiration time. This specifically
means that responses from HTTP/1.0 servers for such URIs SHOULD NOT
be taken from a cache. See section 9.1.1 for related information.
*/
if (ctx.Uri.Query.Length != 0) {
if (ctx.CacheHeaders.Expires == null && (ctx.CacheEntry.IsPrivateEntry?ctx.CacheCacheControl.MaxAge == -1:ctx.CacheCacheControl.SMaxAge == -1)) {
if(Logging.On)Logging.PrintInfo(Logging.RequestCache, SR.GetString(SR.net_log_cache_uri_with_query_has_no_expiration));
return CacheFreshnessStatus.Stale;
}
if (ctx.CacheHttpVersion.Major <= 1 && ctx.CacheHttpVersion.Minor < 1) {
if(Logging.On)Logging.PrintInfo(Logging.RequestCache, SR.GetString(SR.net_log_cache_uri_with_query_and_cached_resp_from_http_10));
return CacheFreshnessStatus.Stale;
}
}
return result;
}