netlogix / nxvarnish
为TYPO3添加Varnish集成
5.0.0
2023-07-31 18:53 UTC
Requires
- php: ^8.1
- typo3/cms-core: ^12.4
- typo3/cms-extbase: ^12.4
- typo3/cms-fluid: ^12.4
- typo3/cms-frontend: ^12.4
Requires (Dev)
- ext-sqlite3: *
- phpunit/phpcov: ^9.0
- typo3/testing-framework: ^8.0
README
为TYPO3添加Varnish集成。确保在TYPO3缓存刷新时刷新Varnish缓存。使用缓存标签刷新所有必要的内容。
兼容性
本扩展的当前版本(5.x)已使用以下版本进行测试
- TYPO3 12.4 在 PHP 8.1 上
- TYPO3 12.4 在 PHP 8.2 上
安装
通过composer安装包。
composer require netlogix/nxvarnish
配置
TYPO3
此扩展在安装工具中提供了一些配置。
- varnishHost: 必需,用于与Varnish通信以清除缓存
- allowCacheLogin: 可选,即使有人登录,也发送正常的缓存头部信息
Varnish
Varnish需要一些特殊的配置来理解缓存标签和BAN请求。请将以下内容添加到您的Varnish .vcl文件中
# WARNING: this is an example how to add tag-based purging to an existing # Varnish configuration. This is *not* a complete configuration! # a list of clients that are allowed to initiate a BAN acl purge { "localhost"; # add whatever IPs are allowed to initiate a BAN "172.16.0.0"/16; # just an example } sub vcl_recv { # ... if (req.method == "BAN") { # only allow cache BANs from known IPs if (!std.ip(req.http.X-Client-Ip, client.ip) ~ purge) { return (synth(405, "Not allowed.")); } # ban using cache tags if (req.http.X-Cache-Tags) { # this will ban all cache objects with matching tags ban("obj.http.X-Cache-Tags ~ " + req.http.X-Cache-Tags); # create an HTTP 200 response and exit return (synth(200, "Ban added.")); } # return an error if no cache tags were provided. # you might need to remove this if you have additional BAN conditions return (synth(400, "Bad Request.")); } # ... } sub vcl_deliver { # ... # remove cache-tags header from response sent to client unset resp.http.X-Cache-Tags; # ... }