I have an article page (Dynamic)| which getting data from service and display article's content on the page. It has certain attributes such as Article Name, Last Updated Date, etc.
This page is cached and shows the content. Only the Last Updated Date is frequently getting change. Couple of solutions that we had :
- Use SDI, But this will make the whole component non-cacheable but we want caching of content.
- Use Ajax call, Right now the implementation is purely written in the backend to get and render the data. Making another call to get one field and wrap on the Date field doesn't seem smart.
Do we have any other workaround that can work for backend driven component where only one field needs to be non-cached?
Thanks,
Dispatcher caches content of the page as a whole.. i.e., as a mapping between the URL used to hit the page and the content delivered by AEM for that URL. On subsequent times calls to that URL, dispatcher delivers the cached content.
If the dynamic parts of the pages are resolved in AEM (through service calls) and the final page content gets rendered from AEM (which is a mix of static and dynamic content), dispatcher has no way of knowing which parts are static vs. dynamic. It delivers the whole page from cache for that URL.
The best option would be segregate the static part from the dynamic values and use mechanisms like AJAX to merge the content. Or you could explore using SSI or Sling dynamic include options to assemble the page on the dispatcher and deliver the page as a whole. Check https://www.cognifide.com/our-blogs/adobe/sling-dynamic-include/ for details
Or if your use case is simple enough with the update to the dynamic content happening based on a set frequency, you could use TTL feature of dispatcher to simply expire the page after a time delay so new content gets cached periodically. Check https://docs.adobe.com/content/help/en/experience-manager-dispatcher/using/configuring/dispatcher-configuration.html for details on TTL configuration