设置Sling Dynamic Include

在Apache HTTP Web Server上运行的AEM Dispatcher中安装和使用Apache Sling Dynamic Include的视频演练。

注意

确保本地安装了最新版本的AEM Dispatcher。

  1. 下载并安装Sling Dynamic Include 包

  2. 通过​http://<host>:<port>/system/console/configMgr/org.apache.sling.dynamicinclude.Configuration​的OSGi Configuration Factory配置Sling Dynamic Include。

    或者,要添加到AEM代码库,请在以下位置创建相应的​sling:OsgiConfig​节点:

    <?xml version="1.0" encoding="UTF-8"?>
    <jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0"
        xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
        jcr:primaryType="sling:OsgiConfig"
        include-filter.config.enabled="{Boolean}true"
        include-filter.config.path="/content"
        include-filter.config.resource-types="[my-app/components/content/highly-dynamic]"
        include-filter.config.include-type="SSI" 
        include-filter.config.add_comment="{Boolean}false"
        include-filter.config.selector="nocache"
        include-filter.config.ttl=""
        include-filter.config.required_header="Server-Agent=Communique-Dispatcher"
        include-filter.config.ignoreUrlParams="[]"
        include-filter.config.rewrite="{Boolean}true"
        />
    <!--
    * include-filter.config.include-type="SSI | ESI | JSI"
    * include-filter.config.ttl is # of seconds (requires AEM Dispatcher 4.1.11+)
    -->
    
  3. (可选)重复最后一步,以允许通过SDI提供可编辑模板🔗的锁定(初始)内容上的组件。 进行额外配置的原因是,可编辑模板的锁定内容是从/conf提供,而不是从/content提供。

    <?xml version="1.0" encoding="UTF-8"?>
    <jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0"
        xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
        jcr:primaryType="sling:OsgiConfig"
        include-filter.config.enabled="{Boolean}true"
        include-filter.config.path="/conf"
        include-filter.config.resource-types="[my-app/components/content/highly-dynamic]"
        include-filter.config.include-type="SSI" 
        include-filter.config.add_comment="{Boolean}false"
        include-filter.config.selector="nocache"
        include-filter.config.ttl=""
        include-filter.config.required_header="Server-Agent=Communique-Dispatcher"
        include-filter.config.ignoreUrlParams="[]"
        include-filter.config.rewrite="{Boolean}true"
        />
    <!--
    * include-filter.config.include-type="SSI | ESI | JSI"
    * include-filter.config.ttl is # of seconds (requires AEM Dispatcher 4.1.11+)
    -->
    
  4. 更新Apache HTTPD Web server的httpd.conf文件以启用Include模块。

    $ sudo vi .../httpd.conf
    
    LoadModule include_module libexec/apache2/mod_include.so
    
  5. 更新vhost文件以遵循include指令。

    $ sudo vi .../vhosts/aem-publish.local.conf
    
    <VirtualHost *:80>
    ...
       <Directory /Library/WebServer/docroot/publish>
          ...
          # Add Includes to enable SSI Includes used by Sling Dynamic Include
          Options FollowSymLinks Includes
    
          # Required to have dispatcher-handler process includes
          ModMimeUsePathInfo On
    
          # Set includes to process .html files
          AddOutputFilter INCLUDES .html
          ...
       </Directory>
    ...
    </VirtualHost>
    
  6. 更新dispatcher.any配置文件以支持(1)nocache选择器,并启用(2)TTL支持。

    $ sudo vi .../conf/dispatcher.any
    
    /rules {
      ...
      /0009 {
        /glob "*.nocache.html*"
        /type "deny"
      } 
    }
    
    小贴士

    如果将上述全局*.nocache.html*规则中的尾随*保留为关闭,则可能会导致子资源🔗请求中出现问题。

    /cache {
        ...
        /enableTTL "1"
    }
    
  7. 在更改其配置文件或dispatcher.any后,始终重新启动Apache HTTP Web Server。

    $ sudo apachectl restart
    
注意

如果您使用Sling Dynamic Includes来提供边缘端包含(ESI),请确保在调度程序缓存🔗中缓存相关的响应标头。 可能的标头包括:

  • "Cache-Control"
  • "Content-Disposition"
  • "Content-Type"
  • "截止日期"
  • "Last-Modified"
  • "ETag"
  • "X-Content-Type-Options"
  • "Last-Modified"

辅助材料

在此页面上