views:

38

answers:

1

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.

Any ideas what is going on here or where I should be going for this information instead?

Update:

It's not client cache because multiple browsers are seeing the same response. Here is a bit of code to explain what's happening.

Web.Config caching settings

<system.web>
    <caching>
        <outputCacheSettings>
            <outputCacheProfiles>
                <clear/>
                <add name="StaticContent" duration="1200" varyByParam="none"/>
                <add name="VaryByParam" duration="1200" varyByParam="*"/>
            </outputCacheProfiles>
        </outputCacheSettings>
    </caching>
     ...
</system.web>

**Action Method With Caching

[OutputCache(CacheProfile = "StaticContent")]
public ActionResult Index()
{
    return View(new CollaborateModel());
}

Code to enumerate the cache, yep it's rough, an this is defined in a controller action method

    var sb = new StringBuilder();

    foreach (KeyValuePair<string, object> item in HttpContext.Cache)
    {
        sb.AppendFormat("{0} : {1}<br />", item.Key, item.Value.ToString());
    }

    ViewData.Add("CacheContents", sb.ToString());

The HttpContext.Cache is where the count is always null, even though the cache seems to be working fine.

A: 

That's probably because the page has been cached downstream on the client browser and not on the server.

Darin Dimitrov