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
This project add HTML fragment cache to your StreamField block in easy way
Background
In Wagtail community, it is popular to use the HTML fragment cache at page level.
This works fine in most of the time. But what if some different page have the same block data and some DB query need be run multiple times when rendering?
In this case, it make sense to make HTML fragment cache work on block level instead of page level.
How it works
cache_block is very similar with Django {% cache %} templatetag, it would pull data from block automatically and use the value to generate fragment cache key.
If value in any block field (even descendants of the block) has changed, new fragment key would be generated and new HTML fragment code would be saved to Cache.
cache_block would check if the page is preview mode, if the page if in preview mode, the HTML fragment cache would not be pulled from cache.
I have used it in my projects and the performance has been improved, especially for some page which contains many db query.