Thursday, May 16, 2019

Donut Caching with Custom SXA Components

In this article Michael shares how to make your custom components, built for SXA, support the donut caching feature.

Today we discovered that one of the forms on our site would simply refresh as you hit the submit button. Further investigation revealed that this component was added to the Sitecore cache. Whenever we cleared the cache the component worked as expected, once. Oh no!

The fantastical SXA module supports donut caching which is made visible through a checkbox on the rendering parameters.

Donut caching setting on the Page List component
This setting is added on the rendering parameters template. Not sure which rendering parameter template is used? You can check it out on the component defined under Layouts.

If you navigate to that item you'll see under the template inheritance a base template for caching.

If you wish to add support for this capability just add the template to your custom rendering parameters template.

At the time of this article, the template ID is {6DA8A00F-473E-487D-BEFE-6834350D5B67} and can be easily added in the Raw values mode of the Content Editor.

Note: When cloning components you will probably use the rendering parameters template included with the original component, in which case you don't even have to do anything special.

If you enjoy using SXA and what to share your appreciation to the team or have questions be sure to check out the #sxa channel on Sitecore Chat.