Index: filelib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lib/filelib.php,v
retrieving revision 1.39.2.7
diff -u -r1.39.2.7 filelib.php
--- filelib.php	25 Sep 2007 15:36:43 -0000	1.39.2.7
+++ filelib.php	26 Sep 2007 12:20:23 -0000
@@ -326,10 +326,19 @@
     //try to disable automatic sid rewrite in cookieless mode
     @ini_set("session.use_trans_sid", "false");
 
+    $gmtlastmodified = gmdate('D, d M Y H:i:s', $lastmodified) . ' GMT';
+    if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
+        if (strtotime($gmtlastmodified) <= strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
+            header('HTTP/1.0 304 Not Modified');
+            header('Cache-control: must-revalidate');
+            exit (0);
+        }
+    }
+
     //do not put '@' before the next header to detect incorrect moodle configurations,
     //error should be better than "weird" empty lines for admins/users
     //TODO: should we remove all those @ before the header()? Are all of the values supported on all servers?
-    header('Last-Modified: '. gmdate('D, d M Y H:i:s', $lastmodified) .' GMT');
+    header('Last-Modified: '. $gmtlastmodified);	
 
     if ($forcedownload) {
         @header('Content-Disposition: attachment; filename='.$filename);
