Search code examples
varnishvarnish-vcl

using the max-age request header


How do I configure my VLC to let Varnish respect the 'Cache-Control max-age' request header?

I noticed that by default varnish delivers cached content, even when I press F5 in my browser (Hence request a 'fresh' copy').


Solution

  • in vcl_hit you can do the following:

    if (req.http.Cache-Control ~ '\no-cache\b`) {
        purge;
        return (restart);
    }
    

    make sure you have imported the std vmod

    import std;