warmup with curl not working

me at ibotty.net me at ibotty.net
Thu Nov 24 19:59:35 CET 2011


i am pretty new to varnish but managed to get it to mostly work in a
pretty short timeframe. i am amazed.

the only problem so far is, that my warmup script is not working.

i warm the cache with
 curl -sSH 'X-Refresh: DOIT' localhost:80/test/

and when accessed again with
 curl localhost:80/test/
it gets the cached copy.

but with firefox, it does not hit the cache the first time (it works the
next time).

a shortened example of my vcl follows (ask, if there is anything
missing). i added return (lookup) after req.hash_always_miss=true
because it did always go to cached copy when i did not return at this point.
if this is not how one should build a vcl please enlighten me .

sub vcl_recv {

  # force a cache refresh for the warmup- and regenerate-script
  # e.g.: curl -H 'X-Refresh: DOIT' $page
  # https://www.varnish-cache.org/trac/wiki/VCLExampleHashAlwaysMiss
  if (req.http.X-REFRESH) {
    set req.hash_always_miss = true;
    return (lookup);

  if (req.url ~ "^test") {
    unset req.http.cookie;
    set req.grace = 12h;
    return (lookup);

sub vcl_fetch {
  set beresp.grace = 24h; # should be the same as max grace in recv

  if (beresp.http.content-type ~ "text") {
    set beresp.do_gzip = true;

  if (req.url ~ "^test") {
    unset beresp.http.set-cookie;
    set beresp.ttl = 14h;
    return (deliver);

sub vcl_hit {
  if (req.request == "PURGE") {
    error 200 "Purged";

sub vcl_miss {
  if (req.request == "PURGE") {
    error 400 "Not in cache.";

the backend sets a vary: accept-encoding header, but it seems not to
make any difference (tested with curl and -H 'Accept-Encoding: gzip,
deflate' and variations).

varnish is 3.0.2-1~1squeeze1 from the debian repo.

thank all of you in advance,
 tobias florek

More information about the varnish-misc mailing list