[英]How to disable cache for a image carousel in TYPO3
My TYPO3 extension has a lib that generates random 5 images from the total stock, for example out of the 100 images. 我的TYPO3扩展程序具有一个lib,可以从总库存中随机生成5张图像,例如,在100张图像中。 This is done randomly every time the page is loaded.
每次加载页面时都会随机执行此操作。 Only default the TYPO3 cache is enabled so every time the same 5 images are showed.
仅默认情况下启用TYPO3缓存,因此每次显示相同的5张图像时。 As the lib is in the header of the website (so on every page) I don't want to disable the cache.
因为lib位于网站的标题中(所以在每个页面上),所以我不想禁用缓存。 How can I disable the cache of only this one lib?
如何禁用仅此一个库的缓存?
TypoScript: TypoScript:
plugin.tx_ExtName.widgets {
Slider = USER
Slider {
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
vendorName = Name
extensionName = ExtName
pluginName = Backend
controller = Customers
action = Slider
switchableControllerActions {
Customers{
1 = Slider
}
}
settings =< plugin.tx_ExtName.settings
persistence =< plugin.tx_ExtName.persistence
view =< plugin.tx_ExtName.view
}
}
lib {
slider < plugin.tx_ExtName.widgets.Slider
}
in your ext_localconf.php
there, where you added your plugin make an usage of the 4-th param of configurePlugin
method 在您的
ext_localconf.php
中,您在其中添加了插件的地方使用了configurePlugin
方法的第4个参数
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'Vendor.' . $_EXTKEY,
'PluginName',
array('Customers' => 'slider',),
array('Customers' => 'slider',) // List non-cachable action(s)
);
Of course fix the VendorName
and PluginName
to your own. 当然,将
VendorName
和PluginName
为您自己的。 It will cause that plugin's actions won't be cached, while whole page will be kept in cache still. 这将导致插件的动作不会被缓存,而整个页面仍将保留在缓存中。
Alternative solution 替代解决方案
You can also use JavaScript for this, just place an JS array of paths in the source code and choose 5 random items on document load it will allow you to avoid non-cached content. 您也可以为此使用JavaScript,只需在源代码中放置一个JS路径数组,并在文档加载时选择5个随机项,这将避免出现未缓存的内容。
Alternative solution: plugin.tx_ExtName.widgets.Slider = USER_INT
. 替代解决方案:
plugin.tx_ExtName.widgets.Slider = USER_INT
。 This makes sure that the Slider plugin is always uncached. 这样可以确保Slider插件始终处于未缓存状态。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.