webvariants / esi
SallyCMS 的插件,Sally 的边缘包含(Edge Side Includes)
dev-default / 0.x-dev
2013-10-07 15:26 UTC
Requires
- php: >=5.3.3
- sallycms/composer-installer: ~1.1
- sallycms/sallycms: >=0.9,<0.10
This package is not auto-updated.
Last update: 2020-08-17 09:31:15 UTC
README
1. 使用方法
- 在
develop/config/esi.yml
中设置 ESI 配置 - 设置您的 Varnish
- 参见 Symfony 2 文档中的 Varnish
设置 req.http.Varnish-Trust-Secret = "xyz_random";
- 要缓存一个模板,请调用
sly_Util_ESI::renderTemplate
sly_Util_ESI::renderTemplate('footer', array('a' => 1), array('max-age' => 10));
模板参数必须是标量,嵌套的标量数组也行。只要能够通过 http_build_query
传递的一切。
在模板内部,您有局部变量 $response
(sly_Response
),$esi
(bool
)和参数。使用 $response
来设置缓存指令(例如 $response->addCacheControlDirective('max-age', 300);
)。$esi
在通过 varnish 或 sally 缓存进行缓存时为 true
。