Created
June 30, 2026 23:00
-
-
Save nosilver4u/ff79133d78e896fe89d9a8b0b112709f to your computer and use it in GitHub Desktop.
SWIS Varnish Integration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| Plugin Name: SWIS Varnish Integration | |
| Version: 1.0.0 | |
| */ | |
| // This enables auto-purge, but only if the X-Varnish header is also detected by SWIS. | |
| add_filter( 'swis_varnish_cache_purge', '__return_true' ); | |
| // The default purge IP/destination is 127.0.0.1, so if your server uses a different IP or port for Varnish, | |
| // uncomment the next line and change the IP/Port in the function below. | |
| // add_filter( 'swis_varnish_ips', 'swis_custom_varnish_ips' ); | |
| function swis_custom_varnish_ips( $varnish_ips ) { | |
| return array( '127.0.0.1:6081' ); | |
| } | |
| // Uncomment the next line to change the HTTP method used to BAN. | |
| //add_filter( 'swis_varnish_url_purge_method', 'swis_custom_varnish_url_purge_method' ); | |
| function swis_custom_varnish_url_purge_method( $purge_method ) { | |
| return 'BAN'; | |
| } | |
| // Additional filters that are available include: | |
| // swis_varnish_full_purge_regex, the purge regex defaults to '.*' | |
| // swis_varnish_x_purge_method_header, uses 'regex' if the above is non-empty, 'default' otherwise. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment