TYPO3:如何仅缓存扩展插件中的某些部分

发布于 2024-12-19 00:08:32 字数 591 浏览 0 评论 0原文

我有这个扩展,显示一些客户数据和嵌入视频 (MP4)。 它由一个缓存的插件组成,因为数据不会更改,除非 TYPO3 后端中的某人对其进行更改并清除缓存。

我们不想使用新的 HTML5 视频标签来在 iPhone/iPad 和 iPad 上播放视频。没有 Flash 的公司。为了不必在我们的服务器上为每个客户存储多个视频文件,我为 flash 浏览器(例如 Firefox,它不会在 HTML5 标签中播放 MP4 视频万岁)制定了后备方法。此方法检查用户浏览器代理,并根据此获取相应的视频标签(FlahsPlayer 或 HTML5)。

现在问题来了:如果我清除TYPO3-Backend中的缓存,然后使用Firefox(使用Flash)加载插件,那么如果我随后在iPhone上加载页面,我会使用Flashplayer获得缓存版本。 但是,如果我清除 TYPO3-Cache,然后使用 iPhone 加载页面,那么 PC 上的 Firefox 随后将获得 HTML5 版本(不适用于 MP4)。

现在的问题是:是否可以只缓存插件的某些部分? 我的意思是:静态客户数据不会经常更改,因此缓存将是完美的。但每次都应检查浏览器代理/使用的视频标签。 我没有找到任何东西 - 或者我搜索的方式错误......

I have this extension showing some customer data plus an embedded video (MP4).
It consists of a cached Plugin, because the data isn't changed, unless someone in the TYPO3-Backend makes changes to it and clears the Cache.

We wan't to use the new HTML5 Video-Tag to be able to play videos on iPhones/iPads & Co. which don't have Flash. To not have to store multiple videofiles on our servers for each customer, i made a fallback-method for flash-browsers (e.g. Firefox, which won't play MP4-Videos in the HTML5-Tag hurray). This method checks the Users Browser-Agent and upon this takes the corresponding Video-Tag (either FlahsPlayer or HTML5).

And here now comes the problem: if I clear Cache in TYPO3-Backend and then load the plugin with Firefox (uses Flash), then if I afterwards load the page on the iPhone, i get the cached version with Flashplayer.
If however i clear TYPO3-Cache and then load the page with an iPhone, then the Firefox on a PC would afterwards get the HTML5-Version (which doesn't work with MP4).

Now the question: is it possible to just cache some parts of a plugin?
I mean: the static customer data won't change that often and therefore caching would be perfect. But the Browser-Agent/used Video-Tag should be checked every time.
I didn't find anything - or i searched the wrong way...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

孤城病女 2024-12-26 00:08:32

可以更改某些扩展的呈现,以允许部分呈现为非缓存。如果扩展允许使用自定义 stdWrap 设置更改部分(例如 tt_news 允许),那么这通常是可能的。不幸的是,情况通常并非如此。

另一种选择可能是大卫建议的。有两个页面 对象定义了不同的 typeNum 和视频的扩展渲染,而 PAGE 对象则由 TYPO3 根据URL 中的 &type GET 属性。

It is possible to alter the rendering of some extensions to allow a part to be rendered non-cached. That's usually possible if the extension allows to alter the parts with your custom stdWrap settings (e.g. tt_news allows that). Unfortunately, that's usually not the case.

The other option might be what David suggested. Having two PAGE objects defined each with different typeNum and extension rendering of the video while the PAGE object is than chosen by TYPO3 depending on the &type GET attribute in the URL.

幻想少年梦 2024-12-26 00:08:32

You can set a Typoscript condition for the user-agent detection and inside define, re-define any settings, including the type of rendering for different browsers. TYPO3 creates a different cache version for each condition. That's actually why too many conditions result in a growth of the cache table.

平安喜乐 2024-12-26 00:08:32

是的,你可以。您可以使用类型参数为您的插件创建虚拟的 2 个页面。然后,您可以使用简单的 Typo3 条件来决定 iPhone 或 Firefox 何时加载页面。类型参数例如用于当前页面的打印页面。不幸的是,这不起作用:

page = PAGE
page.typeNum = 1
stuff = CASE
stuff.key.field = typeNum
stuff.default = TEXT
stuff.default.value = Default
stuff.1 = TEXT
stuff.1.value = One

我总是在浏览器窗口中获得默认文本,而且我也不知道如何强制使用 typenum 。

Yes, you can. You can use the type-parameter to have virtual 2 pages with your plugin. Then you can decide when an iphone or a firefox loads the page with simple Typo3 conditions. The type-parameter is used for example for a print-page of the current page. Unfortunatly this doesn't work:

page = PAGE
page.typeNum = 1
stuff = CASE
stuff.key.field = typeNum
stuff.default = TEXT
stuff.default.value = Default
stuff.1 = TEXT
stuff.1.value = One

I always get the text default in my browser window and I don't know how to force a typenum, too.

苏辞 2024-12-26 00:08:32

非常感谢 cascaval 和 David 的帮助。

对于任何寻找相同东西的人,这里是我最终如何解决它的详细代码:

  1. 通过设置和设置插件设置常量
  2. 使用定义的设置设置一些条件
  3. 实现PHP方法

在setup.txt中

plugin.tx_myext_pi3_item.is_flash_browser = {$plugin.tx_myext_pi3_item.is_flash_browser}  

在constants.txt中:

# cat=tx_myext/Browser Capabilities/21; type=boolean; label= Browser-Agent Switch:Switch used to differentiate between flash based and HTML5 based browsers (e.g. for rendering different players).  
plugin.tx_myext_pi3_item.is_flash_browser = 1

在TypoScript中我设置了以下配置:< /strong>

# Default browser is assumed HTML5 capable:  
plugin.tx_myext.is_flash_browser = 0

# Browser Agent: MSIE prior to version 9.  
[browser = msie] && [version = <9]  
  plugin.tx_myext.is_flash_browser = 1  
[global]

# Browser Agent: Firefox or Opera browser.  
[useragent = *Firefox*] || [useragent = *Opera*]  
  plugin.tx_myext.is_flash_browser = 1  
[global]

# Browser Agent: Google Chrome prior to version 5.  
[useragent = *Chrome*] && [version = <5]  
  plugin.tx_myext.is_flash_browser = 1  
[global]

# Browser Agent: Safari prior to version 3.  
[useragent = *Safari*] && [version = <3]  
  plugin.tx_myext.is_flash_browser = 1  
[global]

# Browser Agent: iPhone, iPad, iPod  
# Must be at the end to override Safari condition if necessary.  
[useragent = *iPhone*] || [useragent = *iPod*] || [useragent = *iPad*]  
  plugin.tx_myext.is_flash_browser = 0  
[global]

最后但并非最不重要的一点是,在 PHP 方法中,我使用以下代码来访问设置:

if ($is_flash_browser == 1) {  
  // Here comes the flash player stuff.  
} else {  
  // Here comes the HTML5 player stuff.  
}

Thanks very much for your help cascaval and David.

For anyone looking for the same thing, here the detailed code how I finally solved it:

  1. Set a plugin setting via Setup & Constants
  2. Set some conditions with the defined setting
  3. Implement the the PHP-Method

in setup.txt:

plugin.tx_myext_pi3_item.is_flash_browser = {$plugin.tx_myext_pi3_item.is_flash_browser}  

In constants.txt:

# cat=tx_myext/Browser Capabilities/21; type=boolean; label= Browser-Agent Switch:Switch used to differentiate between flash based and HTML5 based browsers (e.g. for rendering different players).  
plugin.tx_myext_pi3_item.is_flash_browser = 1

In TypoScript I set the following configuration:

# Default browser is assumed HTML5 capable:  
plugin.tx_myext.is_flash_browser = 0

# Browser Agent: MSIE prior to version 9.  
[browser = msie] && [version = <9]  
  plugin.tx_myext.is_flash_browser = 1  
[global]

# Browser Agent: Firefox or Opera browser.  
[useragent = *Firefox*] || [useragent = *Opera*]  
  plugin.tx_myext.is_flash_browser = 1  
[global]

# Browser Agent: Google Chrome prior to version 5.  
[useragent = *Chrome*] && [version = <5]  
  plugin.tx_myext.is_flash_browser = 1  
[global]

# Browser Agent: Safari prior to version 3.  
[useragent = *Safari*] && [version = <3]  
  plugin.tx_myext.is_flash_browser = 1  
[global]

# Browser Agent: iPhone, iPad, iPod  
# Must be at the end to override Safari condition if necessary.  
[useragent = *iPhone*] || [useragent = *iPod*] || [useragent = *iPad*]  
  plugin.tx_myext.is_flash_browser = 0  
[global]

And last but not least in the PHP-Method I used the following code to access the setting:

if ($is_flash_browser == 1) {  
  // Here comes the flash player stuff.  
} else {  
  // Here comes the HTML5 player stuff.  
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文