It's great to be able to output cache child actions, but how do I invalidate that cache?
I've been trying to use
HttpResponse.RemoveOutputCacheItem or even adding a cache dependency to the response, but neither is working.
Either there is some simple trick to this, or cache entries for child actions have some weird naming schema thats not very visible?
Currently I am not aware about the best way to do this. But one way to do this,
((MemoryCache)OutputCacheAttribute.ChildActionCache).Dispose();
OutputCacheAttribute.ChildActionCache = new MemoryCache("NewDefault");
It also needs to add System.Runtime.Caching assembly.
Update: I think it is better to use just,
OutputCacheAttribute.ChildActionCache = new MemoryCache("NewDefault");
There is no doubt that it is not thread safe.
"And whoever is removed away from the Fire and admitted to Paradise, he indeed is successful." (The Holy Quran)
Excellent Windows VPS Hosting Imran Baloch MVP, MVB, MCP, MCTS, MCPD
OutputCacheAttribute.ChildActionCache = new MemoryCache("NewDefault");
"And whoever is removed away from the Fire and admitted to Paradise, he indeed is successful." (The Holy Quran)
Excellent Windows VPS Hosting Imran Baloch MVP, MVB, MCP, MCTS, MCPD
SiggiG
Member
1 Points
2 Posts
How do I invalidate output cache of child action in MVC3?
Feb 04, 2011 12:09 PM|LINK
It's great to be able to output cache child actions, but how do I invalidate that cache?
I've been trying to use
"ASP.NET MVC 3" outputcache "child action"
imran_ku07
All-Star
45815 Points
7698 Posts
MVP
Re: How do I invalidate output cache of child action in MVC3?
Feb 04, 2011 04:24 PM|LINK
Currently I am not aware about the best way to do this. But one way to do this,
((MemoryCache)OutputCacheAttribute.ChildActionCache).Dispose();
OutputCacheAttribute.ChildActionCache = new MemoryCache("NewDefault");
It also needs to add System.Runtime.Caching assembly.
Update: I think it is better to use just,
OutputCacheAttribute.ChildActionCache = new MemoryCache("NewDefault");
There is no doubt that it is not thread safe.
Excellent Windows VPS Hosting
Imran Baloch MVP, MVB, MCP, MCTS, MCPD
SiggiG
Member
1 Points
2 Posts
Re: How do I invalidate output cache of child action in MVC3?
Feb 06, 2011 12:19 AM|LINK
Thank you :) That did indeed work, but it seems like a very "brute force" way of clearing the output cache of all child actions.
imran_ku07
All-Star
45815 Points
7698 Posts
MVP
Re: How do I invalidate output cache of child action in MVC3?
Feb 06, 2011 06:21 AM|LINK
Update: I think it is better to use just,
OutputCacheAttribute.ChildActionCache = new MemoryCache("NewDefault");
Excellent Windows VPS Hosting
Imran Baloch MVP, MVB, MCP, MCTS, MCPD
ilo
Member
2 Points
1 Post
Re: How do I invalidate output cache of child action in MVC3?
Jun 05, 2012 05:13 PM|LINK
Hello guys,
One year passed and I was just wondering whether we have any more sophisticated solution to this problem.
ilo