emptygif
언어: 한국어

모든 언어 및 프레임워크

Varnish (VCL synthetic) VCL

/pixel.gif 요청에 빈 GIF로 응답하는 Varnish (VCL synthetic)용 VCL 스니펫입니다. GIF는 시작할 때 한 번만 디코딩합니다.

Varnish (VCL synthetic) VCL

파일
default.vcl
실행
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);
    }
}

이 스니펫은 실행해 보고, 반환된 바이트를 비교했습니다.

확인

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

공식 사이트: Varnish (VCL synthetic)