简体   繁体   English

如何在 TYPO3 中进行缓存预热

[英]How to do cache warmup in TYPO3

In another question , there is the recommendation to setup a cache_clearAtMidnight via TypoScript and do a subsequent cache warmup. 在另一个问题中,建议通过 TypoScript 设置cache_clearAtMidnight并进行后续缓存预热。

I would like to know how to do this cache warmup because I did not find a scheduler task to do it.我想知道如何做这个缓存预热,因为我没有找到一个调度程序任务来做它。

(Clearing the entire cache once a day seems excessive, but the cache warmup seems like a good idea to me in any case.) (每天清除一次整个缓存似乎过度,但无论如何,缓存预热对我来说似乎是个好主意。)

As I don't know whether there is an internal mechanism in TYPO3 for cache warming, I built my own little cache warmer based around a simple PHP script (can actually be anything – Python, PHP, Bash,...).由于我不知道 TYPO3 中是否有缓存预热的内部机制,我基于一个简单的 PHP 脚本(实际上可以是任何东西——Python、PHP、Bash ……)构建了自己的小缓存预热器。 The script reads the sitemap.xml and requests each page via cURL .该脚本读取 sitemap.xml 并通过 cURL 请求每个页面

I use a custom user agent to exclude these requests from statistics.我使用自定义用户代理从统计信息中排除这些请求。

curl_setopt($ch, CURLOPT_USERAGENT, 'cache warming - TYPO3');

You can use this ext.您可以使用此分机。 Its simple wget wrapper but you can add it as Scheduler task.它是简单的 wget 包装器,但您可以将其添加为调度程序任务。

https://github.com/visuellverstehen/t3fetch https://github.com/visuellverstehen/t3fetch

There are extensions available to do cache warmup:有可用于缓存预热的扩展:

See also this relatively new blog post (part 1) on caching by Benni Mack:另请参阅 Benni Mack 关于缓存的这篇相对较新的博客文章(第 1 部分):

In general, there are a number of things to consider as well, eg changing cache duration, optimizing for pages to load faster without being cached etc.一般来说,还有很多事情需要考虑,例如改变缓存持续时间,优化页面加载速度而不被缓存等。

Btw, cache_clearAtMidnight does clear the cache at midnight, it sets the expire time to be at midnight.顺便说一句, cache_clearAtMidnight确实在午夜清除了缓存,它将过期时间设置为午夜。 Once the cache has been expired, it will be regenerated.一旦缓存过期,它将被重新生成。 Has the same effect, but might be good to know.具有相同的效果,但可能很高兴知道。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM