diff --git a/theme/jquery.php b/theme/jquery.php
index f4527d2..7991a35 100644
--- a/theme/jquery.php
+++ b/theme/jquery.php
@@ -107,22 +107,20 @@ switch($pathinfo['extension']) {
     default     : $mimetype = 'document/unknown';
 }
 
-if (!empty($_SERVER['HTTP_IF_NONE_MATCH']) || !empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
-    // We do not actually need to verify the etag value because these files
-    // never change, devs need to change file names on update!
-    header('HTTP/1.1 304 Not Modified');
-    header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .' GMT');
-    header('Cache-Control: public, max-age='.$lifetime);
-    header('Content-Type: '.$mimetype);
-    header('Etag: "'.$etag.'"');
-    die;
+$gmt_mtime = gmdate('D, d M Y H:i:s', filemtime($file)) .' GMT';
+
+if ( isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH']) ) {
+    if ($_SERVER['HTTP_IF_MODIFIED_SINCE'] == $gmt_mtime || $_SERVER['HTTP_IF_NONE_MATCH'] == "'$etag'") {
+        header('HTTP/1.1 304 Not Modified');
+        die;
+    }
 }
 
 require_once("$CFG->dirroot/lib/xsendfilelib.php");
 
 header('Etag: "'.$etag.'"');
 header('Content-Disposition: inline; filename="'.$filename.'"');
-header('Last-Modified: '. gmdate('D, d M Y H:i:s', filemtime($file)) .' GMT');
+header('Last-Modified: '. $gmt_mtime);
 header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .' GMT');
 header('Pragma: ');
 header('Cache-Control: public, max-age='.$lifetime);
