設定Sling Dynamic Include

安裝和使用Apache Sling Dynamic Include搭配🔗在Apache HTTP Web Server上執行的AEM Dispatcher的影片逐步說明。

注意

請確定最新版AEM Dispatcher已安裝在本機。

  1. 下載並安裝Sling Dynamic Include 套件組合

  2. 透過OSGi Configuration Factory在​http://<host>配置Sling Dynamic Include:<port>/system/console/configMgr/org.apache.sling.dynamicinclude.Configuration

    或者,若要新增至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),請務必在Dispatcher快取🔗中快取相關的回應標題。 可能的標題包括:

  • "快取控制"
  • "Content-Disposition"
  • "Content-Type"
  • "過期"
  • "上次修改時間"
  • "ETag"
  • "X-Content-Type-Options"
  • "上次修改時間"

支援材料

本頁內容