- Notifications
You must be signed in to change notification settings - Fork50
ASP.NET MVC Extensible Donut Caching brings donut caching to ASP.NET MVC 3 and later. The code allows you to cache all of your page apart from one or more Html.Actions which can be executed every request. Perfect for user specific content.
License
moonpyk/mvcdonutcaching
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
ASP.NET MVC Extensible Donut Caching brings donut caching to ASP.NET MVC 3 and later. The code allows you to cache all of your page apart from one or more Html.Actions which can be executed every request. Perfect for user specific content.
The best way to add donut caching to your MVC project is to use the NuGet package. From within Visual Studio, selectTools | Library Package Manager and then choose either Package Manager Console or Manage NuGet Packages. Via the console, just typeinstall-package MvcDonutCaching and hit return. From the GUI, just search forMvcDonutCaching and click the install button.
The package adds several overloads to the built-in Html.Action HTML helper. The extra parameter in each overload is namedexcludeFromParentCache. Set this to true for any action that should not be cached, or should have a different cache duration from the rest of the page.
@Html.Action("Login","Account",true)
The package also include a DonutOutputCacheAttribute to be used in place of the built-in OutputCacheAttribute. This attribute is typically placed on every controller action that needs be be cached.
You can either specify a fixed duration:
[DonutOutputCache(Duration="300")]publicActionResultIndex(){returnView();}
Or, use a cache profile:
[DonutOutputCache(CacheProfile="FiveMins")]publicActionResultIndex(){returnView();}
If you are using cache profiles, be sure to configure the profiles in the web.config. Add the following within the system.web element:
<caching> <outputCacheSettings> <outputCacheProfiles> <addname="FiveMins"duration="300"varyByParam="*" /> </outputCacheProfiles> </outputCacheSettings></caching>
You can also configure the output cache to use a custom provider:
<caching> <outputCachedefaultProvider="DistributedCacheProvider"> <providers> <addname="DistributedCacheProvider"type="DevTrends.Example.DistributedCacheProvider" /> </providers> </outputCache></caching>
Note, that a custom provider is not included with this project but you can write one fairly easily by subclassingSystem.Web.Caching.OutputCacheProvider. A number of implementations are also available on the web.
A comprehensive guide to MVC Extensible Donut Caching is now available on theDevTrends Blog.
About
ASP.NET MVC Extensible Donut Caching brings donut caching to ASP.NET MVC 3 and later. The code allows you to cache all of your page apart from one or more Html.Actions which can be executed every request. Perfect for user specific content.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors9
Uh oh!
There was an error while loading.Please reload this page.