public async override Task OnActionExecutedAsync(HttpActionExecutedContext actionExecutedContext, CancellationToken cancellationToken)
        {
            if (!Cache.Contains(_cachekey))
            {
                var body = await actionExecutedContext.Response.Content.ReadAsByteArrayAsync();
                var cacheItem = new WebApiCacheItem(actionExecutedContext.Response.Content.Headers.ContentType, body);
                Cache.Add(_cachekey, cacheItem, DateTime.Now.AddSeconds(Server));
            }

            if (IsCacheable(Client, actionExecutedContext.ActionContext))
            {
                actionExecutedContext.ActionContext.Response.Headers.CacheControl = GetClientCache();   
            }
        }
Пример #2
0
        public async override Task OnActionExecutedAsync(HttpActionExecutedContext actionExecutedContext, CancellationToken cancellationToken)
        {
            if (!Cache.Contains(_cachekey))
            {
                var body = await actionExecutedContext.Response.Content.ReadAsByteArrayAsync();

                var cacheItem = new WebApiCacheItem(actionExecutedContext.Response.Content.Headers.ContentType, body);
                Cache.Add(_cachekey, cacheItem, DateTime.Now.AddSeconds(Server));
            }

            if (IsCacheable(Client, actionExecutedContext.ActionContext))
            {
                actionExecutedContext.ActionContext.Response.Headers.CacheControl = GetClientCache();
            }
        }