简体   繁体   English

Symfony2 / Twig缓存过期

[英]Symfony2/Twig cache expiration

Is it possible to set expiration time for Symfony and/or Twig cache. 是否可以设置Symfony和/或Twig缓存的过期时间。 I googled and read the docs for some time and only found the option to auto reload twig templates. 我用Google搜索并阅读了一段时间的文档,但只找到自动重新加载树枝模板的选项。 As I understand this means it will check templates timestamps on every page load which doesn't seem to be a good idea. 据我了解,这意味着它将在每次页面加载时检查模板时间戳,这似乎不是一个好主意。 It would be great if I could set expiration time and after that period it will check timestamps or even recompile all templates fully. 如果我可以设置过期时间,那将是很棒的,在那之后,它将检查时间戳,甚至完全重新编译所有模板。

You can do this in your controller before your class: 您可以在上课之前在控制器中执行以下操作:

/**
* Controller
* @Cache(expires="tomorrow", public="true")
* @author Author
*/

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

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