Caching by default can only be applied to GET actions.
You can build from the source here, or you can install the Nuget version: For Web API 2 (.
Cache Output will take care of server side caching and set the appropriate client side (response) headers for you.
You can specify the following properties: Additionally, the library is setting ETags for you, and keeping them unchanged for the duration of the caching period.
Each individual content type response is cached separately (so out of the box, you can expect the action to be cached as JSON and XML, if you introduce more formatters, those will be cached as well).
The cache API provides additional flexibility (quite a lot, in fact), and can be used to take advantage of caching throughout every layer of an application. Steve's Caching Tips Page Level Output Caching Fragment Caching, User Control Output Caching Caching API, Using the Cache Object Summary Of the many features available in ASP.
Caching can be a good way to get "good enough" performance without requiring a lot of time and analysis.
The solution is going to be somewhat dirty anyway if you can't change the code (the clean way would be to use Sql Cache Dependency).
I don't have a definite answer but I think this works because the page life cycle is invoked at least once.
The built in mechanisms for handling this – using cache expiration, or varying the cached output by one of many parameters – handle most use cases pretty easily.
But other times I need to expire the Output cache programatically, and it’s not entirely obvious how to do this, so I have documented it, here: .
Namely when the page is requested for the first time and thus isn't cached yet.
During that first request the Page_Load is called and the You are right in that typically cached pages are just returned frm the server but this changes when you use Add Validation Callback. NET will call this method to determine whether to returned a cached copy or not.
Also, the main question I have is that I thought Cached pages were simply returned from the server, but the code below indicates that the page life-cycle is being invoked (Page_Load event); I'm confused because the page life-cycle isn't invoked if a cached page is returned, so how would the code in the Page_Load event even fire?