Reputation: 860
I'm creating a ASP.NET MVC 2 application that envolve a section like questions here in stackoverflow (mine is with exams is another kind of application but can be extrapolate to same general idea of SO).
OK I'm creating a cache per page, its mean something like this:
[OutputCache(Duration=60, VaryByParam="page")]
ActionResult AllQuestions(int page){...}
But i want to invalidate that cache when a new question is created. What can i do.
I'm open to suggestions, perhaps this is not the best way to solve this problem
Upvotes: 0
Views: 215
Reputation: 18985
Remember, there are only two hard problems in computer science, and cache invalidation is one them. Don't add the trouble of caching until you need it. As always, avoid premature optimization like this.
Upvotes: 0
Reputation: 36319
Darin is correct. Additionally, if you don't have SQL Server, or don't want to use it as the cache dependency, you can create a custom cache dependency, as 15seconds has a tutorial on: http://www.15seconds.com/issue/040518.htm
Upvotes: 0
Reputation: 1038770
If your questions are stored in a SQL database you could setup an SQL expiration policy so that when data changes the cache will expire.
Upvotes: 4