設定 Sling Dynamic Include

安裝和使用的視頻瀏覽 Apache Sling Dynamic Include 與 調度AEM程式 運行 Apache HTTP Web Server。

注意

確保已在本地安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 節點位於:

    <?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 servers httpd.conf` 檔案以啟用 Include 中。

    $ sudo vi .../httpd.conf
    
    LoadModule include_module libexec/apache2/mod_include.so
    
  5. 更新 vhost 檔案以包含指令。

    $ 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. 始終重新啟動 Apache HTTP Web Server 更改其配置檔案或 dispatcher.any

    $ sudo apachectl restart
    
注意

如果您使用 Sling Dynamic Includes 用於服務邊包括(ESI),然後確保快取相關 調度程式快取中的響應標頭。 可能的標題包括:

  • "快取控制"
  • "內容處置"
  • "內容類型"
  • "過期"
  • "上次修改時間"
  • "ETag"
  • "X內容類型選項"
  • "上次修改時間"

支撐材料

本頁內容