gen:enable_varnish
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
gen:enable_varnish [2024/04/02 03:21] – created kirtisingh | gen:enable_varnish [2025/09/16 10:07] (current) – kirtisingh | ||
---|---|---|---|
Line 32: | Line 32: | ||
Please put this IP w.r.t. any software/ | Please put this IP w.r.t. any software/ | ||
- | With WordPress you can easily use Varnish and enable auto-purging of content (when it changes), by using the [[https:// | + | With WordPress you can easily use Varnish and enable auto-purging of content (when it changes), by using the [[https:// |
+ | |||
+ | Now if the page you changed/ | ||
+ | |||
+ | <code php> | ||
+ | /* action w.r.t. save post in order to flush / URL - start */ | ||
+ | |||
+ | function custom2_save_post_action($post_id, | ||
+ | |||
+ | if ( ' | ||
+ | return; | ||
+ | } | ||
+ | |||
+ | preg_match('# | ||
+ | |||
+ | $vhost_dir=$matches[1]; | ||
+ | |||
+ | $hosts=array(); | ||
+ | |||
+ | $hosts[]=preg_replace('# | ||
+ | $hosts[]=' | ||
+ | |||
+ | for($i=0; | ||
+ | |||
+ | $ch = curl_init(); | ||
+ | |||
+ | curl_setopt($ch, | ||
+ | |||
+ | curl_setopt($ch, | ||
+ | |||
+ | curl_setopt($ch, | ||
+ | 'Host: ' | ||
+ | )); | ||
+ | |||
+ | curl_setopt($ch, | ||
+ | |||
+ | $response = curl_exec($ch); | ||
+ | |||
+ | if (curl_errno($ch)) { | ||
+ | file_put_contents($vhost_dir.'/ | ||
+ | } else { | ||
+ | file_put_contents($vhost_dir.'/ | ||
+ | } | ||
+ | |||
+ | curl_close($ch); | ||
+ | |||
+ | } | ||
+ | |||
+ | |||
+ | } | ||
+ | |||
+ | add_action( ' | ||
+ | |||
+ | /* action w.r.t. save post in order to flush / URL - end */ | ||
+ | </ | ||
In some scenarios auto-purging of Varnish cache may not happen even after using the Proxy Cache Purge plugin. Then in that case Purge/ | In some scenarios auto-purging of Varnish cache may not happen even after using the Proxy Cache Purge plugin. Then in that case Purge/ |
gen/enable_varnish.1712028072.txt.gz · Last modified: 2024/04/02 03:21 by kirtisingh