Using pipe for large files

Christoph Mitasch cmitasch at thomas-krenn.com
Wed Sep 5 11:04:17 CEST 2012


Hello,

some of our users experienced problems when downloading larger files (e.g an iso with 700MB). This happened especially when the clients had a slow Internet connection.

I figured out that this is related to the send_timeout parameter that has changed from 600 to 60 seconds with 3.0.

Since I don't want to have a time limit for slow clients I solved it with the following code:

added to vcl_recv:
  /* Bypass cache for large files.  The x-pipe header is
     set in vcl_fetch when a too large file is detected. */
  if (req.http.x-pipe && req.restarts > 0) {
    remove req.http.x-pipe;
    return (pipe);
  }

added to vcl_fetch:
  # don't cache files larger than 10MB
  /* Don't try to cache too large files.  It appears
     Varnish just crashes if we don't filter them. */
  if (beresp.http.Content-Length ~ "[0-9]{8,}" ) {
    set req.http.x-pipe = "1";
    return (restart);
  }

Is there any disadvantage by using a pipe instead of a pass?

Christoph



More information about the varnish-misc mailing list