title: HTTP if-none-match and if-modified-since and 304 clarification in PHP
body: <p>My question is about how to reply a HTTP 304 "Not Modified" when I receive <strong>both</strong> if-none-match and if-modified-since from a proxy/client request.</p>
  
  <p>From RFC 2616 secttion 14.26 ( <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.26" rel="nofollow noreferrer">http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.26</a> ):</p>
  
  <blockquote>
    <p>If none of the entity tags match, then
    the server MAY perform the requested
    method as if the If-None-Match header
    field did not exist, but MUST also
    ignore any If-Modified-Since header
    field(s) in the request. That is, if
    no entity tags match, then the server
    MUST NOT return a 304 (Not Modified)
    response.</p>
  </blockquote>
  
  <p>I am not sure to understand this statement...</p>
  
  <ol>
  <li>"If none of the entity tags match" in PHP do they speak of <code>$_SERVER['HTTP_IF_NONE_MATCH']</code> vs. my ETags that I sent earlier?</li>
  <li>If I understand correctly this statement, as soon as none of the ETags listed in <code>$_SERVER['HTTP_IF_NONE_MATCH']</code> match my ETags, I stop all verifications and serve the page normally. </li>
  </ol>
  
  <p>Anyone can translate this RFC part in pseudo-code (or PHP code) and/or answer my 2 points above?</p>
  
  <p><strong>EDIT 1:</strong>
  Thank you St.Woland for your answer. Can you (or anyone else) tell me if I'm correct on these 6 points:</p>
  
  <ol>
  <li><p>The format of <code>$_SERVER['HTTP_IF_NONE_MATCH']</code> can be either:</p>
  
  <p>a)If-None-Match: "xyzzy", "r2d2xxxx", "c3piozzzz"</p>
  
  <p>b) If-None-Match: "xyzzy"</p>
  
  <p><strong>and NOT:</strong></p>
  
  <p>c) If-None-Match: "xyzzy, r2d2xxxx, c3piozzzz"</p></li>
  <li><p>If <code>!array_key_exists('HTTP_IF_NONE_MATCH', $_SERVER)</code>, anyTagMatched() returns NULL.</p></li>
  <li><p>As soon as an ETag in <code>$_SERVER['HTTP_IF_NONE_MATCH']</code> match my document ETag, anyTagMatched() returns TRUE.</p></li>
  <li><p>If none of the Etags in <code>$_SERVER['HTTP_IF_NONE_MATCH']</code> are matching my document ETag, <code>anyTagMatched()</code> returns FALSE.</p></li>
  <li><p>If <code>$_SERVER['HTTP_IF_MODIFIED_SINCE']</code> is set and matches my document "last modified" date <code>isExpired()</code> returns FALSE, otherwise return TRUE.</p></li>
  <li><p>As soon as <code>anyTagMatched()</code> returns TRUE, I issue a 304. If anyTagMatched() returned NULL and <code>isExpired()</code> returned FALSE I can issue a 304. In any other situation I serve my page as normal (I also issue the up-to-date Last-Modified and ETag headers).</p></li>
  </ol>