emptygif
Bahasa: Bahasa Indonesia

Semua bahasa dan framework

Varnish (VCL synthetic) VCL

Snippet VCL untuk Varnish (VCL synthetic) yang menjawab request ke /pixel.gif dengan empty GIF, yang di-decode sekali saat startup.

Varnish (VCL synthetic) VCL

File
default.vcl
Jalankan
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);
    }
}

Kami telah menjalankan snippet ini dan membandingkan byte yang dikembalikannya.

Periksa

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

Situs resmi: Varnish (VCL synthetic)