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.
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.
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.
Update: Ok, as of the latest release of MVC (3), it is no longer required and by default no params are used, i.e. only once cache exists. This is the behavior I had previously expected.