So again we are feeling good, we only need to change the output cache duration in one place, so any time we need to change the expiration time it can easily be done.
But wait a minute, on one of our controllers, we are returning a partials view with a RenderAction in the view, but we get the following error.
OutputCacheAttribute for child actions only supports Duration, VaryByCustom, and VaryByParam values. Please do not set CacheProfile, Location, NoStore, SqlDependency, VaryByContentEncoding, or VaryByHeader values for child actions.
Output Cache In MVC
So when using CacheProfile, don't try and use it with a RenderAction as you will receive the error above, instead, you will need to fall back using [OutputCache(Duration = 10, VaryByParam = "id")] on your controller action.
You can download the full code example from GitHub
There is so much more to caching, but I hope you found this brief blog helpful, if so, please leave a comment below.