ユーザ用ツール

サイト用ツール


varnish:11_delete_cache

文書の過去の版を表示しています。


キャッシュ削除

VCLに設定追加

method「PURGE」で対象URLにアクセスすると、対象URLのキャッシュが削除できる。

# vi /etc/varnish/default.vcl
acl purge {
    "localhost";
    "192.168.24.0"/24;
}

sub vcl_recv {
    # allow PURGE from localhost and 192.168.24...
    if (req.method == "PURGE") {
        if (client.ip !~ purge) {
            return(synth(403, "Not allowed"));
        }
        ban("obj.http.x-url ~ " + req.url); # Assumes req.url is a regex. This might be a bit too simple
    }
}

sub vcl_backend_response {
    set beresp.http.x-url = bereq.url;
}

sub vcl_deliver {
    unset resp.http.x-url; # Optional
}

ドメイン配下をまとめて削除

# curl -X PURGE http://test.example.com

特定のURLを削除

# curl -X PURGE http://test.example.com/static/___test___/index.html
varnish/11_delete_cache.1415779936.txt.gz · 最終更新: 2025/02/16 13:50 (外部編集)