After searching a lot, reading every tutorials I\'ve found and asking some questions here, I\'ve finally managed to answer corrctly (at least I think) to if-none-match and i
Here is the function that might help:
function isModified($mtime, $etag) {
return !( (
isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])
&&
strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $mtime
) || (
isset($_SERVER['HTTP_IF_NONE_MATCH'])
&&
$_SERVER['HTTP_IF_NONE_MATCH'] == $etag
) ) ;
}
I suggest that you take a look at the following article: http://www.peej.co.uk/articles/http-caching.html
Update:
[AlexV] Is is even possible to receive if-none-match AND if-modified-since at the same time?
You can definitely have both set. However:
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.
RFC2616 #14.26
Example values (W stands for 'weak'; read more in RFC2616 #13.3.3):
If-None-Match: "xyzzy", "r2d2xxxx", "c3piozzzz"
If-None-Match: W/"xyzzy", W/"r2d2xxxx", W/"c3piozzzz"
If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT
If-None-Match: *
As a special case, the value "*" matches any current entity of the resource.