Skip to content
gohacks.dev
Performance

Varnish VCL Generator

Generate a Varnish 4.1 VCL with a health-checked backend, a PURGE ACL, paths that are never cached, tracking parameters stripped, cookie handling and grace mode.

Free · No sign-up · Your inputs stay in your browser

Input

Generate a Varnish VCL

Output

default.vcl

1,802 characters

Cookies are what usually stop Varnish from caching anything: a request with any Cookie header is passed by the built-in VCL, and analytics sets one on every visitor. This keeps only the session cookie, so logged-out traffic is cached and logged-in traffic is not. Test with varnishd -C -f default.vcl, and watch hit rates with varnishstat.

Runs in this browser. Nothing you paste is sent to a server.

Cookies decide your hit rate

Varnish's built-in logic passes any request with a Cookie header and refuses to cache any response with Set-Cookie. Analytics and consent banners set cookies for every visitor, so without cookie handling nothing is cached. Keeping only the session cookie, as this VCL does, caches logged-out traffic and passes logged-in traffic. The hit rate guide explains the built-in rules.

Grace keeps the site up

With grace, Varnish serves a stale object while it fetches a fresh one in the background, and keeps serving it if the backend is down, within the grace period.

Share

Frequently asked questions

How do I check a VCL for errors?
varnishd -C -f default.vcl compiles it and prints the generated C or the first error. Load it on a running instance with varnishadm vcl.load and vcl.use.
How do I see whether a request was a hit?
The X-Cache header added in vcl_deliver shows HIT or MISS. varnishstat shows the hit ratio, and varnishlog shows why a request was passed.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Keep planning

Similar tools