diff --git a/lib/exe/fetch.php b/lib/exe/fetch.php
index 390e77bfc85e0d85bc3ac996d50ae1789a88cc5c..87c47d7cbccf3d3124b01a0bb3ffbfc3de4cf9e6 100644
--- a/lib/exe/fetch.php
+++ b/lib/exe/fetch.php
@@ -82,11 +82,12 @@
 function sendFile($file,$mime){
   // send headers
   header("Content-Type: $mime");
-  http_conditionalRequest(filemtime($file));
-  list($start,$len) = http_rangeRequest(filesize($file));
   header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
   header('Pragma: public');
   header('Accept-Ranges: bytes');
+  //send important headers first, script stops here if '304 Not Modified' response
+  http_conditionalRequest(filemtime($file));
+  list($start,$len) = http_rangeRequest(filesize($file));
 
   //application mime type is downloadable
   if(substr($mime,0,11) == 'application'){