typo3 - 如何为自定义内容元素定义自定义缓存生命周期?
问题描述
TypoScript 不应该cache
适用于这样的自定义内容元素:
tt_content {
my_custom_element =< lib.contentElement
my_custom_element {
// tested also with stdWrap.cache
cache {
key = my_custom_element
// 10 seconds to test
lifetime = 10
}
templateName = MyCustomElement
dataProcessing.10 = Example\Project\DataProcessing\FetchDataProcessor
dataProcessing.10 {
fetchUri = https://www.example.com/resource
as = fetched_data
}
}
}
...还是我解释错了?
https://docs.typo3.org/m/typo3/reference-typoscript/master/en-us/Functions/Cache.html
我希望为此内容元素定义一个自定义缓存生命周期。
解决方案
可能的解决方案:
tt_content {
// COA_INT to ensure the block .my_custom_element isn't cached
my_custom_element = COA_INT
my_custom_element {
10 =< lib.contentElement
10 {
// Re-add cache for the block .10
cache {
// Use UID of content element when user can edit content of it
key = my_custom_element_{field:uid}
key.insertData = 1
// For test currently 10 seconds
lifetime = 10
}
templateName = MyCustomElement
dataProcessing.10 = Example\Project\DataProcessing\FetchDataProcessor
dataProcessing.10 {
fetchUri = https://www.example.com/resource
as = fetched_data
}
}
}
}
但它有(巨大的)缺点:
- 放置内容元素的页面 HTML 不会被浏览器缓存。
- 静态文件缓存扩展也不适用于此页面。
推荐阅读
- google-apps-script - 谷歌脚本匹配两个工作表之间的单元格并更新第二个工作表中的单元格
- javascript - 如何使用 .map 处理多个输入字段 - ReactJS
- c# - 如果任何财产的价值不同,如何比较?
- jsf - 无法使用 JSF 链接页面
- bash - 从查找结果中排除多个目录
- react-native - 错误:对象作为反应孩子无效?
- haskell - 在 SBV 中组合元组?
- node.js - TypeError:无法读取未定义的“想要”属性:
- r - R-3.6 上的 RDCOMClient 安装问题
- javascript - 解析 Webpack 模块中的 SCSS 文件