title: How to set max-age for non static file responses
body: <p>How to set the max-age parameter for non static file responses in expressjs.</p>
  
  <p>My Code:</p>
  
  <pre><code>app.get('/hello', function(req, res) {
      res.set('Content-Type', 'text/plain');
      res.set({'maxAge':5}); 
      res.send("Hello Message from port: " + port);
      res.status(200).end()
  })
  </code></pre>
  
  <p>I tried this:</p>
  
  <pre><code>    res.set({'max-age':5});
  </code></pre>
  
  <p>Also this:</p>
  
  <pre><code>    res.set({'Cache-Control':'max-age=5'});
  </code></pre>
  
  <p>It is working fine with <code>res.SendFile(file,{maxAge: 5})</code>
  But the problem with the static files is I see the 'max-age' reflecting in the header only on the first http response after the server is started.</p>
  
  <p>All the subsequent response headers show 'max-age = 0' even if the file is served fresh (status 200)</p>