private async Task OnEnterAsync(object source, EventArgs eventArgs) { var app = (HttpApplication)source; var helper = new OutputCacheHelper(new HttpContextWrapper(app.Context)); if (!helper.IsHttpMethodSupported()) { return; } // Create a lookup key. Also store the key in global parameter _key to be used inside OnLeave() later string key = helper.CreateOutputCachedItemKey(null); // Lookup the cache vary using the key object item = await helper.GetAsync(key); if (item == null) { return; } // 'item' may be one of the following: // - a CachedVary object (if the object varies by something) // - a CachedRawResponse object (i.e. it doesn't vary on anything) // First assume it's a CacheVary and try to get the cachedItem with it CachedRawResponse cachedRawResponse = null; var cachedVary = item as CachedVary; if (cachedVary != null) { var cachedItem = await helper.GetAsCacheVaryAsync(cachedVary); if (cachedItem != null) { cachedRawResponse = (CachedRawResponse)cachedItem; } } if (cachedRawResponse == null) { cachedRawResponse = item as CachedRawResponse; } if (cachedRawResponse == null) { return; } // From this point on, we have an Raw Response entry to work with. HttpCachePolicySettings settings = cachedRawResponse.CachePolicy; if (helper.CheckCachedVary(cachedVary, settings)) { return; } if (settings.IgnoreRangeRequests && helper.IsRangeRequest()) { return; } if (helper.CheckHeaders(settings)) { return; } if (await helper.CheckValidityAsync(key, settings)) { return; } if (!helper.IsContentEncodingAcceptable(cachedVary, cachedRawResponse.RawResponse)) { return; } helper.UpdateCachedResponse(settings, cachedRawResponse.RawResponse); //Re-insert entry in kernel cache if necessary if (helper.IsKernelCacheAPISupported() && cachedRawResponse.KernelCacheUrl != null) { OutputCacheUtility.SetupKernelCaching(cachedRawResponse.KernelCacheUrl, app.Context.Response); } //Complete request app.CompleteRequest(); }
public string SetupKernelCaching(string originalCacheUrl, HttpContextBase context) { return(OutputCacheUtility.SetupKernelCaching(originalCacheUrl, context.ApplicationInstance.Response)); }
public void SetContentBuffers(HttpContextBase context, ArrayList buffers) { OutputCacheUtility.SetContentBuffers(context.ApplicationInstance.Response, buffers); }
public IEnumerable <KeyValuePair <HttpCacheValidateHandler, object> > GetValidationCallbacks(HttpContextBase context) { return(OutputCacheUtility.GetValidationCallbacks(context.ApplicationInstance.Response)); }
public ArrayList GetContentBuffers(HttpContextBase context) { return(OutputCacheUtility.GetContentBuffers(context.ApplicationInstance.Response)); }
public CacheDependency CreateCacheDependency(HttpContextBase context) { return(OutputCacheUtility.CreateCacheDependency(context.ApplicationInstance.Response)); }