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

Avatar

Avatar
Establish
Community Manager
kautuk_sahni
Community Manager

Likes

1,200 likes

Total Posts

6,394 posts

Correct reply

1,147 solutions
Top badges earned
Establish
Coach
Originator
Contributor 2
Contributor
View profile

Avatar
Establish
Community Manager
kautuk_sahni
Community Manager

Likes

1,200 likes

Total Posts

6,394 posts

Correct reply

1,147 solutions
Top badges earned
Establish
Coach
Originator
Contributor 2
Contributor
View profile
kautuk_sahni
Community Manager

21-03-2021

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.

Replies

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,442 likes

Total Posts

3,314 posts

Correct reply

941 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,442 likes

Total Posts

3,314 posts

Correct reply

941 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
Arun_Patidar
MVP

22-03-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.