So I am working on an inherited site that has overridden default render mvc controller with custom one. That has mapping code that hydrates model. This all works however its slow and once site starts to get 100+ users it falls over. So caching was added however we need to invalidate the cache of items when they are published.
The cache attribute is set to varyByCustom="url" so this will generate a donut cache key like
and that works. However this assumes you have domain set on root node of site. Ideally I want the key to be generated based on node id. Does anyone know how to do this? I am guessing you create your own donut cache attribute?
donut cache invalidate cache
So I am working on an inherited site that has overridden default render mvc controller with custom one. That has mapping code that hydrates model. This all works however its slow and once site starts to get 100+ users it falls over. So caching was added however we need to invalidate the cache of items when they are published.
The cache attribute is set to varyByCustom="url" so this will generate a donut cache key like
Now in my on published event i try to clear the cache like so :
The item is not cleared because the generated key looks like:
So I updated my code to clear cache like so:
and that works. However this assumes you have domain set on root node of site. Ideally I want the key to be generated based on node id. Does anyone know how to do this? I am guessing you create your own donut cache attribute?
Regards
Ismail
I'll give an example setup:
On Action/Controller:
In web.config:
In Global.asax:
So basically on your caching profiles you can configure which custom keys should be used for creating the caching key.
The GetVaryByCustomString-method allows providing the logic for those custom keys.
you my friend are a legend that works a treat.
is working on a reply...