Support » Plugin: Varnish/Nginx Proxy Caching » Exact match header not being set in plugin

  • Hi,

    I’ve been trying to get exact matches working as I need to actually invalidate caches where query params are mandatory.

    The plugin contains example VCL files, where X-VC-Purge-Method is checked. This header is never set in PHP code though. It always resorts to default or regex, instead of exact:

        public function purge_url($url)
        {
            $p = parse_url($url);
    
            if (isset($p['query']) && ($p['query'] == 'vc-regex')) {
                $pregex = '.*';
                $purgemethod = 'regex';
            } else {
                $pregex = '';
                $purgemethod = 'default';
            }
    
            if (isset($p['path'])) {
                $path = $p['path'];
            } else {
                $path = '';
            }
    
            $schema = apply_filters('vcaching_schema', $this->useSsl ? 'https://' : 'http://');
    
            foreach ($this->ipsToHosts as $key => $ipToHost) {
                $purgeme = $schema . $ipToHost['ip'] . $path . $pregex;
            }
        }

    What I would expect is this:

            if (isset($p['query']) && ($p['query'] == 'vc-regex')) {
                $pregex = '.*';
                $purgemethod = 'regex';
            } else if (isset($p['query'])) {
                $pregex = '?' . $p['query'];
                $purgemethod = 'exact';
            } else {
                $pregex = '';
                $purgemethod = 'default';
            }
  • The topic ‘Exact match header not being set in plugin’ is closed to new replies.