Efficiently Caching : Experience Fragments on dispatcher | AEM Community Blog Seeding | Community
Skip to main content
kautuk_sahni
Community Manager
Community Manager
March 22, 2021

Efficiently Caching : Experience Fragments on dispatcher | AEM Community Blog Seeding

  • March 22, 2021
  • 3 replies
  • 3923 views

BlogImage.jpg

Efficiently Caching : Experience Fragments on dispatcher by AEM Concepts

Abstract

Problem
Suppose you are using XF/Experience Fragments included in template for Header and footer. Header and Footer XF are included in the template structure. XF are not getting updated on the pages since the content pages are cached with header and footer html’s as part of the pages. So only updating the XF wont invalidate the pages. The entire content hierarchy would need to be invalidated to see the updated XF content on pages.



Approach
SDI can be used in this case. All pages would reference a single html file at a shared location. Once XF is activated the shared file will be invalidated and updated. Since the content pages are just referencing the shared file they would also show updated content.

SDI setup is Only required on Publish.

The XF html will be included as a server side includes in the template as a separate request to a XF with xf selector. This will be get cached on the dispatcher below /conf.

Cache will be invalidated using acs commons dispatcher cache flush osgi config, once the XF are published.

Enable commenting to see the below comments in page source.


Implementation
Sling dynamic include jar is NOT available in aem osgi ootb. So we need to deploy the jar to osgi.

Add dependency in parent pom and demo.all pom.

Read Full Blog

Efficiently Caching : Experience Fragments on dispatcher

Q&A

Please use this thread to ask the related questions.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

3 replies

arunpatidar
Community Advisor
Community Advisor
March 22, 2021

You can invalidate the page cache as well using acs common similer to conf

prop.rules.hierarchical="[/content/experience-fragments/demo/en-us/global/.* =/conf/demo/settings/wcm/templates]"

prop.rules.hierarchical="[/content/experience-fragments/demo/en-us/global/.* =/content/demo]"

Then you will not face issues with caching when publishing global content.

If other use cases are required then SDI can be implemented.

Arun Patidar
Level 2
August 2, 2022

Hi @arunpatidar   

As you have mentioned : You can invalidate the page cache as well using acs common similer to conf

Do you mean : I have 1000 content pages and these pages, uses experience fragments and uses caching. Now, whenever we modify exp. fragment and once activated, this will clear XF file. And also, we need to clear those 1000 pages?  Or we need to follow what @kautuk_sahni   has mentioned.

- Thanks

Level 2
August 3, 2022

Yes, it will delete those 1000 cached pages from dispatcher as well if you have rules like

prop.rules.hierarchical="[/content/experience-fragments/demo/en-us/global/.* =/content/demo]"

Check for more info https://adobe-consulting-services.github.io/acs-aem-commons/features/dispatcher-flush-rules/index.html 


Thanks @arunpatidar  for the clarification. In this case, it is better to clear files related to exp. fragment, not the all 1000 pages.

Level 2
August 5, 2022

One more query @kautuk_sahni   @arunpatidar 

In any page, if I use my content fragment or content fragment list component, and if I add/modify the content fragment item under DAM and after publishing. I need to get these modified/new content in my page. (Note: I might use the content fragment/list in many pages.)   In this case too, I need to use Sling Dynamic Include for the content fragment component? Is configuration is bit different compare to exp. fragment?

arunpatidar
Community Advisor
Community Advisor
August 5, 2022

Hi,

The list will not be updating automatically because page's generated html already cached at dispatcher, so you have to republish the page.

I will not suggest to use SDI here because the content fragment list component maybe used in 1-2 pages, so activate manually.

Do not increase load on publish unnecessarily.

Arun Patidar