title: Browser Cache Control, Dynamic Content
body: <p><strong>Problem:</strong> I can't seem to get FireFox to cache images sent from a dynamic server</p>
  
  <p><strong>Setup:</strong> Static Apache Server with reverse proxy to a dynamic server (mod_perl2) at backend.</p>
  
  <p>Here is the request URL for the server.  It is sent to the the dynamic server, where the cookie is used to validate access to the image:</p>
  
  <p><strong>Request Headers</strong></p>
  
  <pre><code>Host:  &lt;OBSCURED&gt;
  User-Agent:  Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.15) Gecko/2009102815 Ubuntu/9.04 (jaunty) Firefox/3.0.15
  Accept:  image/png,image/*;q=0.8,*/*;q=0.5
  Accept-Language: en-us,en;q=0.5
  Accept-Encoding: gzip,deflate
  Accept-Charset:  ISO-8859-1,utf-8;q=0.7,*;q=0.7
  Keep-Alive:  300
  Connection:  keep-alive
  Referer: &lt;OBSCURED&gt;
  Cookie:  pz_cred=4KCNr0RM15%2FJCOt%2BEa6%2BL62z%2Fxvbp2xNQHY5pJw5d6Q
  Pragma:  no-cache
  Cache-Control: no-cache
  </code></pre>
  
  <p>The dynamic server streams the image back to the server, and provides the following response:</p>
  
  <p><strong>Response Headers</strong></p>
  
  <pre><code>Date:  Tue, 24 Nov 2009 04:28:07 GMT
  Server:  Apache/2.2.11 (Ubuntu) mod_apreq2-20051231/2.6.0 mod_perl/2.0.4 Perl/v5.10.0
  Cache-Control: public, max-age=31536000
  Content-Length:  25496
  Content-Type:  image/jpeg
  Via: 1.1 127.0.1.1:8081
  Keep-Alive:  timeout=15, max=75
  Connection:  Keep-Alive
  </code></pre>
  
  <p>So far, so good (me thinks).  However, <strong>on reload of the page</strong>, the image does not appear cached, and a request is again sent:</p>
  
  <p><strong>Request Headers</strong></p>
  
  <pre><code>Host: &lt;OBSCURED&gt;
  User-Agent:  Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.15) Gecko/2009102815 Ubuntu/9.04 (jaunty) Firefox/3.0.15
  Accept:  image/png,image/*;q=0.8,*/*;q=0.5
  Accept-Language: en-us,en;q=0.5
  Accept-Encoding: gzip,deflate
  Accept-Charset:  ISO-8859-1,utf-8;q=0.7,*;q=0.7
  Keep-Alive:  300
  Connection:  keep-alive
  Referer: &lt;OBSCURED&gt;
  Cookie:  pz_cred=4KCNr0RM15%2FJCOt%2BEa6%2BL62z%2Fxvbp2xNQHY5pJw5d6Q
  Cache-Control: max-age=0
  </code></pre>
  
  <p>It doesn't seem that request should happen as the browser should have cached the image.  As it is, a 200 response is received, same as the first, and the image appears to be re-fetched (although the browser does appear to be using the cached images).</p>
  
  <p>The problem appears to be hinted at by the Cache-Control: max-age=0 in the reload request header, above.</p>
  
  <p>Does anyone know why this is happening?  Perhaps it is the <strong>Via</strong> header in the response that is causing the problem?</p>