diff --git a/lib/filelib.php b/lib/filelib.php
index <HASH>..<HASH> 100644
--- a/lib/filelib.php
+++ b/lib/filelib.php
@@ -637,9 +637,18 @@ function send_temp_file_finished($path) {
  * @param bool $forcedownload If true (default false), forces download of file rather than view in browser/plugin
  * @param string $mimetype Include to specify the MIME type; leave blank to have it guess the type from $filename
  */
-function send_file($path, $filename, $lifetime=86400 , $filter=0, $pathisstring=false, $forcedownload=false, $mimetype='') {
+function send_file($path, $filename, $lifetime = 'default' , $filter=0, $pathisstring=false, $forcedownload=false, $mimetype='') {
     global $CFG, $COURSE, $SESSION;
 
+    // MDL-11789, apply $CFG->filelifetime here
+    if ($lifetime === 'default') {
+        if (!empty($CFG->filelifetime)) {
+            $filetime = $CFG->filelifetime;
+        } else {
+            $filetime = 86400;
+        }
+    }
+
     session_write_close(); // unlock session during fileserving
 
     // Use given MIME type if specified, otherwise guess it using mimeinfo.
MDL-<I>, apply $CFG->filelifetime in send_file function.