SallyCMS 的插件,Sally 的边缘包含(Edge Side Includes)

安装: 0

依赖项: 0

建议者: 0

安全: 0

类型:sallycms-addon

dev-default / 0.x-dev 2013-10-07 15:26 UTC

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 传递的一切。

在模板内部,您有局部变量 $responsesly_Response),$esibool)和参数。使用 $response 来设置缓存指令(例如 $response->addCacheControlDirective('max-age', 300);)。$esi 在通过 varnish 或 sally 缓存进行缓存时为 true