views:

13

answers:

1

I've done zero research on this, I'm just curious.

The OutputCacheAttribute class in ASP.NET MVC requires a value for Duration and VaryByParam. I get why Duration is required, but not VaryByParam.

A: 

If they didn't require you configure this, you could unintentionally get tens of thousands of cached copies of the same exact page, thus invalidating the benefits of output caching.

Therefore there are two solutions--One, check each output to see if it is a duplicate, or two, make the cache dependent on the values of certain page-related variables. The first was probably too cost prohibitive, so they went with the second.

They're trying to guide you into the 'pit of success' by forcing you to realize that a page may be rendered differently when certain query string/POST parameters are present, and by forcing you to think about what output caching means and how it works.

Will