opencontent/ocfoshttpcache-ls

OpenContent FosHttpCache for eZPublish Legacy

安装数: 3,490

依赖项: 0

建议者: 0

安全: 0

星标: 0

关注者: 6

分支: 1

开放问题: 0

类型:ezpublish-legacy-extension

dev-master 2021-01-15 11:58 UTC

This package is auto-updated.

Last update: 2024-09-15 20:20:34 UTC


README

该扩展将FosHttpCache库集成到eZ Publish 4.x(Legacy)中

主要优点是能够使用FosHttpCache使用的方法根据用户上下文缓存页面

安装

  • 配置Varnish(请参阅doc/default.vcl)

  • site.ini中设置HTTPHeaderSettings,例如

[HTTPHeaderSettings]
CustomHeader=enabled
OnlyForAnonymous=disabled
OnlyForContent=enabled
Cache-Control[]
Cache-Control[/]=public, must-revalidate, max-age=259200, s-maxage=259200
HeaderList[]=Vary
Vary[/]=X-User-Context-Hash
  • 安装和配置扩展

  • 重新生成autoloads并清空ini缓存

配置

site.ini中配置Varnish端点、端口或IP

[VarnishSettings]
VarnishHostName=varnish.example.com
VarnishPort=80
VarnishServers[]=10.0.0.1:1234
VarnishServers[]=127.0.0.1:80

或者使用[Event]Listeners[]=ocfoshttpcache/varnish_server@MyVarnishServerCallable

可以通过在site.ini中使用StaticCache(默认配置)来配置扩展

[ContentSettings]
StaticCache=enabled
StaticCacheHandler=Opencontent\FosHttpCache\StaticCache

失效Varnish缓存

为了失效缓存,预定义了一个可配置的自定义头X-Instancesite.ini

[HTTPHeaderSettings]
HeaderList[]=X-Instance
X-Instance[/]=example

或者使用[Event]Listeners[]=ocfoshttpcache/instance_identifier@MyIdentifierCallable

建议在VirtualHost级别也设置此头,以便标记资产和图像。

注意

StaticCache处理器考虑site.ini [ContentSettings]CacheThreshold的值来计算是否清空整个缓存。

通过site.ini中的块确保对_fos_user_context_hash模块的访问

[RoleSettings]
PolicyOmitList[]=_fos_user_context_hash 

如果需要选择性地失效Varnish缓存,则可以使用varnish/dashboard模块

待办事项

提供模板操作符以插入自定义标签

{fos_httpcache_tag('mytag')}
{fos_httpcache_tag(['tag-one', 'tag-two'])}