title: Varnish: how to cache a URL with parameters - need to strip multiple parameters but not all
body: <p>I'm testing a revised Varnish config and I need to see if certain URLs are hitting the cache or not. It seems not to like multiple parameters.</p>
  
  <p>The Varnish config change is to not treat URLs with certain parameters as unique content. E.g.</p>
  
  <pre><code>/news/tech
  /news/tech?itq=1001
  /news/tech?itq=1002&amp;ito=3553
  </code></pre>
  
  <p>should all be equivalent.</p>
  
  <p><strong>Scenario 1</strong></p>
  
  <p>Requesting a page that hasn't been cached yet:</p>
  
  <pre><code>curl -I 'http://example.com/news/tech'
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>X-Varnish-Cache: MISS
  </code></pre>
  
  <p>Sending the same request a second time gives this result:</p>
  
  <pre><code>X-Varnish-Cache: HIT
  </code></pre>
  
  <p><strong>Scenario 2</strong></p>
  
  <p>Requesting the above URL again, but with a parameter:</p>
  
  <pre><code>curl -I 'http://example.com/news/tech?itq=1001'
  </code></pre>
  
  <p>That is one of the parameters to not treat as unique content.</p>
  
  <p>Result:</p>
  
  <pre><code>X-Varnish-Cache: HIT
  </code></pre>
  
  <p><strong>Scenario 3</strong></p>
  
  <p>Requesting with a second parameter:</p>
  
  <pre><code>curl -I 'http://example.com/news/tech?itq=1001&amp;ito=3553'
  </code></pre>
  
  <p>Response:</p>
  
  <pre><code>X-Varnish-Cache: MISS
  </code></pre>
  
  <p>It seems like the Varnish config works for ? but not for &amp;</p>
  
  <p>Here's the relevant line in my Varnish config:</p>
  
  <pre><code>  set req.url = regsuball(req.url, "([\?|\&amp;])+(utm_campaign|utm_content|utm_medium|utm_source|utm_term|ITO|et_cid|et_rid|qs|itq|ito|itx\[idio\])=[^&amp;\s]*&amp;?", "\1");
  </code></pre>
  
  <p>I guess this is only running once, so it won't strip out multiple parameters. How would I do that?</p>