mwillebrands / sitecore-scriban-extensions

MIT License
2 stars 1 forks source link

Smart Publish on Scriban Includes does not clear cache on CD / Live servers #1

Open beyondsun opened 6 months ago

beyondsun commented 6 months ago

Hi @mwillebrands first, I want to express my gratitude for your significant contributions to developing this module, which has been incredibly beneficial.

We're encountering a caching issue on CD servers.

Issue Description: Specifically, after smart publishing, either the Scriban Include Item or the pages referencing these includes via Renderings do not have their cache refreshed, leading to outdated content being displayed.:

What we have for implementation ? Sitecore version: 10.0.0 (SXA) Azure PAAS - Scaled CD instances

Issue: 1.Created a new Rendering Variant with scriban
2.Created a new Scriban Include with a Unique Key which is included in RV as per documentation. the content contains a basic form field with label.

The content from scriban includes renders and works as expected upon first publish in CD.

Then any subsequent changes made to the scriban include item and publishing or republishing the scriban includes folder and children along with item gives incorrect results in CD only (CM works as excepted)

In addition this happens only with Scriban includes, ex: Changes to the parent Rendering Variant that references these includes are immediately reflected on publishing, which suggests the issue might be isolated to Scriban includes.

Have you encountered similar caching challenges, and do you have any insights or solutions? Your assistance would be greatly appreciated

mwillebrands commented 6 months ago

Hi,

Thank you for the clear description of your issue, and it sounds correct as there are no real references from the Rendering Variant to the Scriban Include item.

Two solutions come to mind:

  1. Change the eventhandler that listens to the Publish event so that it not only checks for the Scriban Include template ID but also for the Scriban template ID (easy quick fix, means that any time a Scriban item is published the Scriban Include cache is cleared, even if the Scriban item did not include an Include)
  2. Add logic to the Save event of a Scriban item and update the Link Database within Sitecore, so that the Scriban item has a reference to the Scriban Include, this way it is automatically published and you can use the "Links" functionally in the Content Editor. (extended fix, but adds more functionality which is nice).

I've added the code change for option 1 as it is an easy fix, would you be able to see if that solves your issue? You can check the changed code here.

beyondsun commented 6 months ago

Thank you Maarten for the quick response and being patient with my delayed test outcome. Unfortunately the solution 1) is not related but is a good outcome I see the value there. Let me try the solution 2) and will post here if I had this resolved with any other trials.

Thanks Suneeth

beyondsun commented 3 months ago

@mwillebrands created a new PR for your review here

  1. includes your changes on evenhandler to include Scriban template ID
  2. Clear cache on publish end remote OnPublishEndRemote