title: How to disable Varnish Cache from within a PHP script?
body: <p>I distribute a PHP script and recently a lot of people are having trouble with varnish cache on shared hosting accounts. </p>
  
  <p>This is the code at the top of the PHP script. However I still get "Varnish: HIT" in response headers (and the script doesn't work correctly). </p>
  
  <pre><code>header('Pragma: no-cache');
  header('Cache-Control: private, no-cache, no-store, max-age=0, must-revalidate, proxy-revalidate');
  header('Expires: Tue, 04 Sep 2012 05:32:29 GMT');
  </code></pre>
  
  <p>One hosting provider said it was impossible to disable varnish from within a PHP script, even by setting the cache headers like above. This seems .. well .. silly? But seems to match my experience.</p>
  
  <p>So is there a way to disable/skip varnish from within PHP? Or does varnish (by default) just ignore these cache headers set by PHP? </p>
  
  <hr>
  
  <p>Thanks Jens-André Koch - I'll include varnish instructions along with the PHP script to make it ignore no-cache responses:</p>
  
  <pre><code>sub vcl_fetch {
          if (beresp.http.cache-control ~ "(no-cache|private)" ||
              beresp.http.pragma ~ "no-cache") {
                  set beresp.ttl = 0s;
          }
  }
  </code></pre>