title: Web front end caching best practices for site?
body: <h2>Summary</h2>
  
  <p>As I'm looking on stackoverflow and around the net, I find that there is a general lack of good documentation on best practices for caching a high performance site that uses sessions. It would be helpful if we can share some ideas around some basic building blocks particularly around caching. For the purpose of this discussion, I'm avoiding memcache and focusing on the caching of static and pages that are fully generated.</p>
  
  <p>So to set up the scenario, imagine a web server (say nginx), reverse proxy (say varnish), app server (whatever), db server (say mysql). </p>
  
  <h2>Anonymous</h2>
  
  <ol>
  <li>Static items (gif/jpg etc.)</li>
  <li>Semi dynamic (js/css)</li>
  <li>Dynamic</li>
  </ol>
  
  <h2>Logged In</h2>
  
  <ol>
  <li>Static</li>
  <li>Semi dynamic (js/css)</li>
  <li>Dynamic</li>
  </ol>
  
  <p>Generally speaking, all of the Anon should be cacheable and most of Logged In (ignore dynamic, no ESI for now).</p>
  
  <p><strong>Anon #1</strong></p>
  
  <ul>
  <li>Set far-off Expires</li>
  <li>Set ETag if possible</li>
  <li>Cache-Control: max-age=315360000</li>
  </ul>
  
  <p><strong>Anon #2</strong> 
  (have the reverse proxy cache the result if dynamically generated else Anon #1 rules apply)</p>
  
  <ul>
  <li>Cache-Control: public, s-maxage=3000</li>
  </ul>
  
  <p><strong>Anon #3</strong></p>
  
  <ul>
  <li>Cache-Control: public, s-maxage=300</li>
  </ul>
  
  <p><strong>Logged In #1</strong></p>
  
  <ul>
  <li>Set far-off Expires</li>
  <li>Set ETag if possible</li>
  <li>Cache-Control: max-age=315360000</li>
  </ul>
  
  <p><strong>Logged In #2</strong> 
  (have the reverse proxy cache the result if dynamically generated else Logged In #1 rules apply)</p>
  
  <ul>
  <li>Cache-Control: public, s-maxage=3000</li>
  </ul>
  
  <p><strong>Logged In #3</strong></p>
  
  <ul>
  <li>Cache-Control: s-maxage=0, must-revalidate</li>
  </ul>
  
  <p>What are your suggestions? I'll update the post as answers come in.</p>