Reputation: 2858
So I have this CustomOutputCacheProvider
which extents the abstract class OutputCacheProver
because my web page can be viewed in different languages. Language is known by the server. I mean the server knows the current culture of UI (example "en-US"). So the reason I extended the OutputCacheProver
is to let this language handling stay on server side like how it was.
Basically for different languages the Custom provider stores different data. But the problem is, (everything's okay but this,the provider is registered in web.config) for ChildActionOnly
actions this provider is not used. I mean, suppose the action that return a PartialView
and has a ChildActionOnly
and OutputCache
attributes on it.
The PartialView
is not cached by the provider I registered. Or I don't know, something else is happening. For anything else that I've tried my provider is working perfecly. I suppose for Child action caching ASP.NET MVC is using some other provider itself. Anyway, what can be done in here ?
Upvotes: 0
Views: 278
Reputation: 1062600
I suspect your best bet would be to override GetVaryByCustomString
and ensure that the custom string includes the language. Then it should work find from any provider layer / implementation. However, it may be that this is only inspected when VaryByCustom
has a value, which means tweaking your [OutputCache(...)]
to include something - for example [OutputCache(... VaryByCustom="language;...")]
Note that if you already have a GetVaryByCustomString
(for use with VaryByCustom
), your language-specific parts should be in addition to all other concerns.
Note: with this approach, you wouldn't need a custom output-cache provider in the first place.
Upvotes: 2