if_modified_since.php 378 B

1234567891011121314151617181920
  1. <?php
  2. error_reporting(0);
  3. $ts = $_REQUEST['ts'];
  4. $ifModifiedSince = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? stripslashes($_SERVER['HTTP_IF_MODIFIED_SINCE']) : false;
  5. if ($ifModifiedSince == $ts) {
  6. header('HTTP/1.0 304 Not Modified');
  7. die; // stop processing
  8. }
  9. header("Last-Modified: " . $ts);
  10. if ( $ifModifiedSince ) {
  11. echo "OK: " . $ts;
  12. } else {
  13. echo "FAIL";
  14. }
  15. ?>