設定Sling Dynamic Include
在Apache HTTP Web Server上執行AEM Dispatcher時,安裝及使用Apache Sling Dynamic Include的影片逐步解說。
NOTE
確保本機已安裝最新版AEM Dispatcher。
-
下載並安裝Sling Dynamic Include 套件。
-
透過 http://<host>:<port>/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+) -->
-
(選擇性)重複上一個步驟,允許透過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+) -->
-
更新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
-
更新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>
-
更新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" }
-
變更組態檔或
dispatcher.any
後,請一律重新啟動Apache HTTP Web Server。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"
c92bdb17-1e49-4e76-bcdd-89e4f85f45e6