예제 #1
0
 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));
 }
예제 #3
0
 protected void when_getting_response_caching()
 {
     try
     {
         cache = CacheResponse.GetResponseDirective(_proxy, _browser, _server);
     }
     catch (Exception e)
     {
         exception = e;
     }
 }
예제 #4
0
        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;
        }