{"id":5723,"date":"2019-01-21T13:56:09","date_gmt":"2019-01-21T08:26:09","guid":{"rendered":"\/?p=5723"},"modified":"2019-08-22T16:50:42","modified_gmt":"2019-08-22T11:20:42","slug":"sling-dynamic-include-sdi","status":"publish","type":"post","link":"https:\/\/www.argildx.us\/technology\/sling-dynamic-include-sdi\/","title":{"rendered":"Sling Dynamic Include (SDI): Dynamically Include Page Components"},"content":{"rendered":"
In CQ or AEM, most of the pages remain static. Hence, caching of the pages is very useful with dispatchers or any other available AEM plugins\/connectors. Imagine a scenario where homepage of news agency must show the hot news which is different for different regions, however, because of caching it is displaying the same news in all the regions. Strange! To rescue from these, live scenarios, the application may require certain elements\/components of the page to be dynamically included. In AEM, Sling Dynamic Include (SDI) provides this functionality.<\/p>\n
<\/p>\n
Let\u2019s elaborate SDI integration with AEM 6.4, Dynamic Include 3.0.0 and Dispatcher 2.4.<\/p>\n
<\/p>\n
<\/p>\n
\u00a0<\/strong><\/p>\n Install Sling Dynamic Include Bundle using the following steps:<\/p>\n \u00a0 \u00a0 \u00a0 4. Check the Start Bundle checkbox and browse the location where the bundle is downloaded and Click on install\/update button<\/p>\n <\/p>\n Once the installation of the bundle is completed, verify it by searching Dynamic Include. It should be in an active state.<\/p>\n <\/p>\n <\/p>\n After installation of the SDI bundle, the next step is to configure the component to be dynamically included.<\/p>\n Please find below the brief description of each OSGI config used above:<\/p>\n Apache HTTP Server is set up as a caching proxy in front of the AEM. This means that the include will be done by the http server and not by the sling engine.<\/p>\n Edge Site Includes can be used as an alternative to SSI, it is evaluated by CDN. ESI has to have some proxy that is able to process its tags and often made available as part of CDN.<\/p>\n Using JSI will replace dynamic components with ajax tags, so they are loaded by the browser. If included component has some JS code, it may not work properly, as it won\u2019t be initialized immediately after a page is loaded.<\/p>\n \u00a0<\/strong><\/p>\n \u00a0<\/strong><\/p>\n After completion of Step 1 and Step 2 on publishing instance, Dispatcher configurations need to be updated as explained below:<\/p>\n 1. Include(If already present, make sure uncommented) the mod_include module in Apache Web server’s httpd.conf file:<\/p>\n 2. Update virtual host configuration file<\/p>\n a. Find the following lines in the dispatcher.conf file<\/p>\n modify as below<\/p>\n b. Add Includes to Options directive:<\/p>\n 3.\u00a0 Update the httpd.conf to enable SDI.<\/p>\n a. Add \u201cIncludes\u201d to Options directive to enable SSI includes used by Sling Dynamic Include<\/p>\n b. Specify what file types are to be processed by Includes filter.<\/p>\n 4. Update rules.any or dispatcher.any depending where the cache rules are defined for the publish instance.<\/p>\n Make sure the selector ‘nocache’ used here is same as defined in OSGI config (include-filter.config.selector = ‘nocache’) explained in Step 2.<\/p>\n 5. Restart the server using any of the below commands:<\/p>\n <\/p>\n After setting up the SDI, it\u2019s time to verify the changes. Follow the below steps:<\/p>\n <\/p>\n <\/p>\n","protected":false},"excerpt":{"rendered":" In CQ or AEM, most of the pages remain static. Hence, caching of the pages is very useful with dispatchers or any other available AEM plugins\/connectors. Imagine a scenario where homepage of news agency must show the hot news which is different for different regions, however, because of caching it is displaying the same news … Read more<\/a><\/p>\n","protected":false},"author":6,"featured_media":6635,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","content-type":"","footnotes":""},"categories":[66],"tags":[25,27,114,115],"yst_prominent_words":[2283,1041,1031,1042,1032,1029,1034,1037,1035,2285,2286,1033,2282,1040,1038,1028,1039,1030,1027,1036],"acf":[],"yoast_head":"\n\n
Step 2:<\/strong><\/h6>\n
<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<jcr:root xmlns:sling=\"http:\/\/sling.apache.org\/jcr\/sling\/1.0\"xmlns:cq=\"http:\/\/www.day.com\/jcr\/cq\/1.0\"\r\n xmlns:jcr=\"http:\/\/www.jcp.org\/jcr\/1.0\"xmlns:nt=\"http:\/\/www.jcp.org\/jcr\/nt\/1.0\"\r\n jcr:primaryType=\"sling:OsgiConfig\"\r\n include-filter.config.enabled=\"{Boolean}true\"\r\n include-filter.config.path=\"\/content\"\r\n include-filter.config.resource-types=\"[my-app\/components\/content\/dynamic_included_component]\"\r\n include-filter.config.include-type=\"SSI\"\r\n include-filter.config.add_comment=\"{Boolean}false\"\r\n include-filter.config.selector=\"nocache\"\r\n include-filter.config.ttl=\"\"\r\n include-filter.config.required_header=\"Server-Agent=Communique-Dispatcher\"\r\n include-filter.config.ignoreUrlParams=\"[]\"\r\n include-filter.config.rewrite=\"{Boolean}true\"\r\n\/>\r\n<\/pre>\n
\n
\n
\n
\n
\n
Step 3:<\/strong><\/h6>\n
LoadModule include_module modules\/mod_include.so<\/pre>\n
<IfModule dispatcher_module>\r\n\tSetHandler dispatcher-handler\r\n<\/IfModule>\r\n<\/pre>\n
<IfModule dispatcher_module>\r\n\tSetHandler dispatcher-handler\r\n<\/IfModule>\r\nSetOutputFilter INCLUDES\r\n<\/pre>\n
<VirtualHost *:80>\r\n...\r\n<Directory \/>\r\n\t\t\t\t...\r\nOptions FollowSymLinks Includes \r\nAllowOverride None\r\n...\r\n\t\t<Directory>\r\n\t\t...\r\n<\/VirtualHost>\r\n<\/pre>\n
<Directory \/mnt\/var\/www\/html>\t\r\n ...\r\n Options Indexes FollowSymLinks Includes \r\n\t... \r\n AddOutputFilter INCLUDES .html \r\n\tAddOutputFilterByType INCLUDES text\/plain text\/html\r\n ...\r\n <\/Directory>\r\n<\/pre>\n
\/0008 {\r\n \t\t\/glob \"*.nocache.html*\"\r\n \t\t\/type \"deny\"\r\n \t}\r\n<\/pre>\n
sudo apachectl restart OR sudo service httpd restart\r\n\r\n<\/pre>\n
Verification<\/strong><\/h5>\n
\n