设置 Sling Dynamic Include
安装和使用的视频演练 Apache Sling Dynamic Include 替换为 AEM调度程序 运行于 Apache HTTP Web Server.
NOTE
确保本地安装了最新版本的AEM Dispatcher。
-
下载并安装 Sling Dynamic Include 捆绑.
-
配置 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+) -->
-
(可选)重复上一步,以允许组件位于 可编辑模板的锁定(初始)内容 通过以下方式提供 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" }
-
始终重新启动 Apache HTTP Web Server 更改其配置文件或
dispatcher.any
.code language-shell $ sudo apachectl restart
NOTE
如果您使用 Sling Dynamic Includes 为了提供edge-side include (ESI),请确保缓存相关 调度程序缓存中的响应标头. 可能的标头包括:
- "Cache-Control"
- "内容处置"
- "Content-Type"
- "过期"
- "Last-Modified"
- "ETag"
- "X-Content-Type-Options"
- "Last-Modified"
支持材料
recommendation-more-help
c92bdb17-1e49-4e76-bcdd-89e4f85f45e6