設定 Sling Dynamic Include

安裝及使用的影片逐步解說 Apache Sling Dynamic Include 替換為 AEM傳送器 執行於 Apache HTTP Web Server.

NOTE
請確定本機已安裝了最新版的AEM Dispatcher。
  1. 下載並安裝 Sling Dynamic Include 組合.

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

    或者,若要新增至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. 永遠重新啟動 Apache HTTP Web Server 變更其組態檔或 dispatcher.any.

    code language-shell
    $ sudo apachectl restart
    
NOTE
如果您使用 Sling Dynamic Includes 若要提供edge-side include (ESI),請務必快取相關 Dispatcher快取中的回應標頭. 可能的標頭包括:
  • "Cache-Control"
  • "Content-Disposition"
  • "Content-Type"
  • "過期"
  • "Last-Modified"
  • "ETag"
  • "X-Content-Type-Options"
  • "Last-Modified"

支援材料

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