You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+12-26Lines changed: 12 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -357,18 +357,16 @@ Essentially this is a convenience for setting
357
357
'''
358
358
359
359
### Clearing the Cache 'on publish'
360
-
The DotNet CacheTagHelper really isn't designed to make it easy to clear the cache 'on command' it's designed to vary and then fall out of cache after a period of time, but what if you want your cache instantly refreshed when a publish takes place? This tag helper has the possibility to 'vary' the cache when a piece of content/media or dictionary is published.
360
+
The Umbraco convention with other Cache Helpers, eg Html.CachedPartial is to clear all memory caches whenever any item is published in the Umbraco Backoffice. By default the our-cache tag helper will do the same, however you can turn this part off on an individual TagHelper basis by setting update-cache-key-on-publish="false".
361
361
362
362
'''cshtml
363
-
<our-cacheupdate-cache-key-on-publish="true">[Your Long Running Expensive Code Here]</our-cache>
363
+
<our-cacheupdate-cache-key-on-publish="false">[Your Long Running Expensive Code Here]</our-cache>
364
364
'''
365
365
366
-
With this set to true any publish will remove the item from a list of tracked cached items and therefore a fresh version of the TagOutput will be displayed.
367
-
368
-
This is set to True by default, how opinionated of us, so you only need to explictly use the attrivute if you wish to set this to false and not clear the cache item on Umbraco content/media/dictionary publish.
366
+
(NB if you had a thousand tag helpers on your site, all caching large amounts of content, and new publishes to the site occurring every second - this might be detrimental to performance, so do think of the context of your site before allowing the cache to be cleared on each publish)
369
367
370
368
### Examples
371
-
All examples will skip the cache for Umbraco preview mode and debug mode, and evicit cache items anytime Umbraco publishes content, media or dictionary items.
369
+
All examples will skip the cache for Umbraco preview mode and debug mode, and evict cache items anytime Umbraco publishes content, media or dictionary items.
<!-- Need to clear cache when phone number changes on different node -->
395
-
</our-cache>
396
-
397
380
<our-cache>
398
-
<!-- Default of 20mins Global navigation -->
399
-
<!-- A global naviagtion need to clear cache when phone number changes on different node -->
381
+
<!-- A global naviagtion needs to be updated across entire site when phone number changes on homepage node -->
400
382
<partial name="Navigation" />
401
383
</our-cache>
402
-
```
403
-
404
-
(NB if you had a thousand tag helpers on your site, all caching large amounts of content, and new publishes to the site occurring every second - this might be detrimental to performance, so do think of the context of your site before setting this value)
405
384
385
+
```
386
+
This example will turn off the automatic clearing of the tag helper cache if 'any page' is published, but still clear the cache if the individual page is published:
[](https://www.youtube.com/watch?v=3fkDs0NwIE8)
0 commit comments