1

I am searching for a way to define a region or block within a template that Twig will not cache.

For an example of where this would be used:

On a website that shows a list of results after a search, there is a region of filters. Each filter is saved as a session and when the document is not cached the filter values match the session.

Enabling Twig caching prevents this feature from working, but if it was possible to specify a region to not cache, I could exclude the filter area the site would function properly.

Is this possible with Twig?

4

1 回答 1

0

您使用的是哪种缓存?ESI 缓存允许您为模板的不同部分提供不同的缓存规则,因此如果您使用它,您可以定义哪些区域应该被缓存,哪些不应该:http://symfony.com/doc/master/book/http_cache。 html#edge-side-includes

如果您不熟悉 ESI 缓存,KNP 提供了一个方便的教程: http: //knpuniversity.com/screencast/new-symfony-2.2/fragments-esi-caching

于 2013-04-12T10:54:56.463 回答