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.
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.
<!-- https://mvnrepository.com/artifact/org.apache.sling/org.apache.sling.dynamic-include -->
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.dynamic-include</artifactId>
<version>3.1.6</version>
</dependency>
Configure
org.apache.sling.dynamicinclude.Configuration
OOTB when a page is loaded a separate call(network tab) is made to get the
structure of the template and render on the page. The call starts with
/conf… We need to SDI this call for the XF component.
OSGI config attribute “include-filter.config.path” means repo will be
searched below /conf/demo/settings/wcm/templates and resources have
resourcetype = demo/component/experiencefragment will be sling dynamically
included.
The included/cached XF’s will be created below /conf
SDI config - Only required on Publish
Please Note that the cache will be created below /conf
Cache below /conf should be cleared when experience fragment is
activated.
Above was later renamed and updated to..
com.adobe.acs.commons.replication.dispatcher.impl.DispatcherFlushRulesImpl-template_xf.xml
prop.rules.hierarchical="[/content/experience-fragments/demo/en-us/global/.*
=/conf/demo/settings/wcm/templates]"