设置Sling Dynamic Include

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

NOTE
确保本地安装了最新版本的AEM Dispatcher。
  1. 下载并安装Sling Dynamic Include 捆绑包

  2. 通过​ http://<主机>:<端口>/system/console/configMgr/org.apache.sling.dynamicinclude.Configuration ​上的OSGi Configuration Factory配置Sling Dynamic Include。

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

    code language-xml
    <?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提供了可编辑模板的锁定内容。

    code language-xml
    <?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模块。

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

    code language-shell
    $ sudo vi .../vhosts/aem-publish.local.conf
    
    code language-shell
    <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支持。

    code language-shell
    $ sudo vi .../conf/dispatcher.any
    
    code language-shell
    /rules {
      ...
      /0009 {
        /glob "*.nocache.html*"
        /type "deny"
      }
    }
    
    note tip
    TIP
    在上述glob *.nocache.html*规则中将尾部*保留为关闭状态可能会导致子资源请求🔗出现问题。
    code language-shell
    /cache {
        ...
        /enableTTL "1"
    }
    
  7. 始终在更改配置文件或dispatcher.any后重新启动Apache HTTP Web Server。

    code language-shell
    $ sudo apachectl restart
    
NOTE
如果您使用Sling Dynamic Includes为边缘端包含(ESI)提供服务,请确保在调度程序缓存🔗中缓存相关的响应标头。 可能的标头包括:
  • "Cache-Control"
  • "内容处置"
  • "Content-Type"
  • "过期"
  • "Last-Modified"
  • "ETag"
  • "X-Content-Type-Options"
  • "Last-Modified"

支持材料

recommendation-more-help
c92bdb17-1e49-4e76-bcdd-89e4f85f45e6