https://github.com/netlogix/nxvarnish
https://github.com/netlogix/nxvarnish
php typo3 varnish
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/netlogix/nxvarnish
- Owner: netlogix
- License: mit
- Created: 2022-05-24T07:02:37.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2025-02-05T16:18:53.000Z (4 months ago)
- Last Synced: 2025-02-05T17:28:44.940Z (4 months ago)
- Topics: php, typo3, varnish
- Language: PHP
- Size: 84 KB
- Stars: 2
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# TYPO3 extension nxvarnish
[](https://github.com/netlogix/nxvarnish)
[](https://get.typo3.org/version/13)
[](https://php.net/)
[](https://github.com/netlogix/nxvarnish/actions)Adds varnish integration to TYPO3. Ensures varnish caches are flushed when TYPO3
caches are flushed. Uses cache tags to flush all necessary content.## Compatibility
The current version (6.x) of this extension has been tested using these
versions:- TYPO3 13.4 on PHP 8.3
- TYPO3 13.4 on PHP 8.4## Installation
Install the package via composer.
```bash
composer require netlogix/nxvarnish
```## Configuration
### TYPO3
This extension provides some configuration in Install Tool.
- varnishHost: **required**, needed to communicate with Varnish in order to
purge
caches
- allowCacheLogin: _optional_, send normal cache headers even when someone is
logged in### Varnish
Varnish needs some special configuration to understand cache tags and BAN
requests.
Add this to your Varnish .vcl:```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;# ...
}```