I've faced a problem when varyByParam set in web.config was not respected.
<add name="MyName" duration="5" varyByParam="none" />
//this works
[OutputCache(CacheProfile = "MyName", VaryByParam = "None")]
//this doesn't
[OutputCache(CacheProfile = "MyName")]
I've looked into source code, and I've found
private OutputCacheParameters _cacheSettings = new OutputCacheParameters { VaryByParam = "*" };
in OutputCacheAttribute. If I understand it right, it means that varyByParam from CacheProfile will be overridden with "*".
// Pick up the settings from the configuration settings profile first
...
// Start overriding options from the directive
if (cacheSettings.IsParameterSet(OutputCacheParameter.VaryByParam)) {
varyByParam = cacheSettings.VaryByParam;
}
<add name="MyName" duration="5" varyByParam="none" />
//this works
[OutputCache(CacheProfile = "MyName", VaryByParam = "None")]
//this doesn't
[OutputCache(CacheProfile = "MyName")]
I've looked into source code, and I've found
private OutputCacheParameters _cacheSettings = new OutputCacheParameters { VaryByParam = "*" };
in OutputCacheAttribute. If I understand it right, it means that varyByParam from CacheProfile will be overridden with "*".
// Pick up the settings from the configuration settings profile first
...
// Start overriding options from the directive
if (cacheSettings.IsParameterSet(OutputCacheParameter.VaryByParam)) {
varyByParam = cacheSettings.VaryByParam;
}