title: Invalidating cached content, If-Modified Headers?
body: <p>I'm having a peculiar problem:</p>
  
  <pre><code>PHP SCRIPT:
  
  // checks If-Modified-Since header (if nothing has changed)
  // Sends HTTP/1.0 304 Not Modified
  // Sends Cache-control: public, must-revalidate
  // exits
  
  // if NO If-Modified-Since or something has changed
  // builds content
  // Sends Last-Modified: [DATE TIME]
  // Sends Cache-control: public, must-revalidate
  // exits
  </code></pre>
  
  <p>I am using jQuery AJAX to attempt to refresh the content on demand, I am trying to do this by altering the If-Modified-Since header with a DATE TIME in the past, using the "beforeSend" param.</p>
  
  <p>This is currently what happens:</p>
  
  <ol>
  <li>Request is made, 200 OK response with fresh content</li>
  <li>Subsequent requests get a 304 response and browser pulls from cache</li>
  <li>CONTENT IS CHANGED on the server</li>
  <li>A request is made with modified If-Modified-Since header (no URL string altering), 200 OK response with fresh content</li>
  <li>Subsequent requests (without altering If-Modified-Since header) seems to retrieve old content from step #1</li>
  </ol>
  
  <p>I guess im under the impression that at step #4, the browsers content should have been refreshed, what am i missing?</p>
  
  <p>I setup a little test so you can try and see what i mean: <a href="http://tweetplenty.com/test/test2.php" rel="nofollow noreferrer">http://tweetplenty.com/test/test2.php</a> ... use FF and firebug if you can as im using console.log() ... here is the order of operations:</p>
  
  <ol>
  <li><p>the "normal" link will do a request to <a href="http://tweetplenty.com/test/test.php" rel="nofollow noreferrer">http://tweetplenty.com/test/test.php</a> without modifying if-modified-since ... subsequent requests using the "normal" link should return a 304 (it should return 200 OK every 60 seconds)</p></li>
  <li><p>the "if-modified-since" link will do a request to <a href="http://tweetplenty.com/test/test.php" rel="nofollow noreferrer">http://tweetplenty.com/test/test.php</a> WITH modified if-modified-since header, the browser will return new content.</p></li>
  <li><p>clicking "normal" again at this point returns the previously cached data, I would think that it should have refreshed the data after clicking the "if-modified-since" link.</p></li>
  </ol>
  
  <p>If you want to checkout the test scripts themselves here you go: <a href="http://tweetplenty.com/test/test.zip" rel="nofollow noreferrer">http://tweetplenty.com/test/test.zip</a></p>