Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is the HttpContext.Cache count always zero?
    text
    copied!<p>I set up a few pages with OutputCache profiles and confirmed that they are being cached by using multiple browsers and requests to retrieve the page with a timestamp which matched across all requests. When I try to enumerate the HttpContect.Cache it is always empty. </p> <p>Any ideas what is going on here or where I should be going for this information instead?</p> <p>Update:</p> <p>It's not client cache because multiple browsers are seeing the same response. Here is a bit of code to explain what's happening.</p> <p><strong>Web.Config caching settings</strong></p> <pre><code>&lt;system.web&gt; &lt;caching&gt; &lt;outputCacheSettings&gt; &lt;outputCacheProfiles&gt; &lt;clear/&gt; &lt;add name="StaticContent" duration="1200" varyByParam="none"/&gt; &lt;add name="VaryByParam" duration="1200" varyByParam="*"/&gt; &lt;/outputCacheProfiles&gt; &lt;/outputCacheSettings&gt; &lt;/caching&gt; ... &lt;/system.web&gt; </code></pre> <p>**Action Method With Caching</p> <pre><code>[OutputCache(CacheProfile = "StaticContent")] public ActionResult Index() { return View(new CollaborateModel()); } </code></pre> <p><strong>Code to enumerate the cache, yep it's rough, an this is defined in a controller action method</strong></p> <pre><code> var sb = new StringBuilder(); foreach (KeyValuePair&lt;string, object&gt; item in HttpContext.Cache) { sb.AppendFormat("{0} : {1}&lt;br /&gt;", item.Key, item.Value.ToString()); } ViewData.Add("CacheContents", sb.ToString()); </code></pre> <p>The HttpContext.Cache is where the count is always null, even though the cache seems to be working fine.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload