title: Varnish 3 - how to set maximum age in http headers
body: <p>I am using Varnish 3.0.3 and to use it to leverage browser caching by setting a maximum age in the HTTP headers for static resources. I tried adding the following configuration to default.vcl:</p>
  
  <pre><code>sub vcl_fetch {
    if (beresp.cacheable) {
      /* Remove Expires from backend, it's not long enough */
      unset beresp.http.expires;
  
      /* Set the clients TTL on this object */
      set beresp.http.cache-control = "max-age=900";
  
      /* Set how long Varnish will keep it */
      set beresp.ttl = 1w;
  
      /* marker for vcl_deliver to reset Age: */
      set beresp.http.magicmarker = "1";
    }
  }
  
  sub vcl_deliver {
    if (resp.http.magicmarker) {
      /* Remove the magic marker */
      unset resp.http.magicmarker;
  
      /* By definition we have a fresh object */
      set resp.http.age = "0";
    }
  }
  </code></pre>
  
  <p>This is copied from <a href="https://www.varnish-cache.org/trac/wiki/VCLExampleLongerCaching" rel="nofollow">https://www.varnish-cache.org/trac/wiki/VCLExampleLongerCaching</a> . Maybe I just made a typo. On restart of Varnish, it no longer worked.</p>
  
  <p>I have two questions. Is this the correct way to do it for Varnish 3? If so, what am I doing wrong? Secondly, is there a way to test the Varnish configuration file, before a restart? Something along the ways of what Apache has with "/sbin/service httpd configtest". That catches mistakes before going live. Thank you.</p>