static void SetupLocalCaching(CacheProxyAttribute proxy, ResponseCachingState response) { TimeSpan parsedMaxAge; if (proxy.MaxAge != null && TimeSpan.TryParse(proxy.MaxAge, out parsedMaxAge)) { response.LocalCacheEnabled = true; response.LocalCacheMaxAge = parsedMaxAge; } }
bool CanCache(ResponseCachingState state, ICommunicationContext env) { // we only cache 200 to GET for now return state.LocalCacheEnabled && env.Request.HttpMethod == "GET" && env.Response.StatusCode == 200; ; //&& (ContainsExpire(response) || // ContainsMaxAge(response) || // ContainsSharedMaxAge(response)); }
protected void when_getting_response_caching() { try { cache = CacheResponse.GetResponseDirective(_proxy, _browser, _server); } catch (Exception e) { exception = e; } }
public static ResponseCachingState GetResponseDirective( CacheProxyAttribute proxy, CacheBrowserAttribute browser, CacheServerAttribute server) { ValidateProxyAttribute(proxy); var instructions = CacheVisibility(proxy, browser) .Concat(CacheRevalidation(proxy, browser)) .Concat(CacheMaxAge(proxy, browser)); var response = new ResponseCachingState(instructions); // SetupLocalCaching(proxy, response); return response; }