I have an MVC application with approx 20 controllers.
In this application I want to cache certain views (mostly partials) for 60 seconds, i.e. the result would only change once per minute, even if the underlying data changed during that minute.
Seems simple enough.
The complication is that the partials show different data dependant on the currently logged in user. How can I make sure that the cache is per user using MVC3?
You can use
OutputCacheAttributeto affect output caching on on a controller or action-by-action basis, and useVaryByCustom.Place that on the controllers, then go into your Global.asax.cs and override
GetVaryByCustomString: