I want to be able to set a long expiration time for certain items that the user loads with a GET request.
I want to say โit's good for 10 minutesโ (i.e. I want to set the Expires header to +10 minutes). Requests are fragments of HTML that are displayed on the page through AJAX, and they are good for a user session. I do not want to return to the server and get 304 if they need them again. I want the browser cache to instantly give me the same element.
I found an article that almost a year ago on caching and compressing an MVC filter . This creates a custom ActionFilter to change the expires header. I already use a compression filter that works fine for some custom css that I generate (94% compression ratio!).
I have two main problems:
1) I really have to use this method. I am fine with this, but if in MVC or OutputCache functionality there really is no functionality to do this for me? In "traditional" ASP.NET, I always just set the Expires header manually, but we can't do this anymore - at least not in the controller.
2) If I use this filter method - it will generally interfere with the OutputCache policy that I want to control in web.config. I kind of think that the two are mutually exclusive, and you don't need both, but I'm not quite sure.
asp.net-mvc outputcache
Simon_Weaver
source share