A common issue with Experience fragment(XF) is cache invalidation of pages referencing the XF. When a Experience fragment(XF) is modified and published, pages which reference the XF are not updated and still shows old XF content. This happens because the XF content/html is cached as part of each page instead of being referenced from a shared location.
Page needs to be explicitly activated/invalidated to view the updated content of the XF. This can be quite tedious and unpractical at times for the authors. There are multiple ways to tackle this problem.
The choice of the solution depends on the scope and scale of the website. Smaller website with less page views and traffic might decide to go with options 1,2 or 3. However if we want to build a more performant and scalable website option 4 would be the way to go.
- (Not Recommended) Flush the site cache when a experience fragment is published.
- Sling dynamic include with TTL : where the page will always check for latest XF content after a given interval of time.
- Custom Replication Event listener : Which invalidates only the specific pages referencing the updated XF.
- Sling dynamic include with ACS Commons dispatcher flush : XF’s will be included using server side includes and stored at a shared location and would be invalidated on activation. Since this is a broader topic it is covered here separately.
Flush the site cache
This can be done by multiple ways. Lowering the statfile level to 1 which would mean that any XF activated would flush the entire site cache. Another way to do this is to use the ACS flush rules.
Though functionally this would resolve the issue but it is definitely not recommended to flush the entire site cache as it can have performance implications.
Sling dynamic include with TTL
Use Sling dynamic include configuration and add a TTL upon which XF content gets fetched again from publish. So a page will always get the latest XF content after a given internal of time. SDI setup is covered in more detail here.
Continue reading here