Skip to content

Commit

Permalink
Can now handle a $CFG->filelifetime to determine cacheability of files
Browse files Browse the repository at this point in the history
  • Loading branch information
moodler committed Apr 1, 2004
1 parent c5dfc3b commit 66e5f95
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions file.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
require_once("config.php");
require_once("files/mimetypes.php");

$lifetime = 86400;
if (empty($CFG->filelifetime)) {
$CFG->filelifetime = 86400; /// Seconds for files to remain in caches
}

if (isset($file)) { // workaround for situations where / syntax doesn't work
$pathinfo = $file;
Expand Down Expand Up @@ -46,8 +48,8 @@
$mimetype = mimeinfo("type", $filename);

header("Last-Modified: " . gmdate("D, d M Y H:i:s", $lastmodified) . " GMT");
header("Expires: " . gmdate("D, d M Y H:i:s", time() + $lifetime) . " GMT");
header("Cache-control: max_age = $lifetime"); // a day
header("Expires: " . gmdate("D, d M Y H:i:s", time() + $CFG->filelifetime) . " GMT");
header("Cache-control: max_age = $CFG->filelifetime");
header("Pragma: ");
header("Content-disposition: inline; filename=$filename");
header("Content-length: ".filesize($pathname));
Expand Down

0 comments on commit 66e5f95

Please sign in to comment.