emptygif
Sprache: Deutsch

Alle Sprachen und Frameworks

Varnish (VCL synthetic) VCL

Ein VCL-Snippet für Varnish (VCL synthetic), das Anfragen an /pixel.gif mit dem leeren GIF beantwortet, das einmal beim Start dekodiert wird.

Varnish (VCL synthetic) VCL

Datei
default.vcl
Ausführen
varnishd -f /etc/varnish/default.vcl -a :8080
vcl 4.1;

import blob;

backend default none;  # or your real backend

sub vcl_recv {
    if (regsub(req.url, "\?.*$", "") == "/pixel.gif") {
        return (synth(200, "OK"));
    }
}

sub vcl_synth {
    if (resp.status == 200 && regsub(req.url, "\?.*$", "") == "/pixel.gif") {
        set resp.http.Content-Type = "image/gif";
        set resp.http.Cache-Control = "no-store";
        set resp.body = blob.decode(BASE64, encoded="R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==");
        return (deliver);
    }
}

Wir haben dieses Snippet ausgeführt und die zurückgegebenen Bytes verglichen.

Prüfen

curl -sI http://localhost:8080/pixel.gif

Offizielle Website: Varnish (VCL synthetic)