diff options
| -rw-r--r-- | app/df.php | 9 | 
1 files changed, 8 insertions, 1 deletions
| @@ -31,7 +31,8 @@ require_once "class/mesg.class.php";  /*   * Serve the resource at the given URI in response to the current   * request.  When finished, this function will exit PHP and terminate - * this script. + * this script.  The response instructs the client to cache the + * result for 24 hours.   */  function serveResource(string $uri, ?string $filename = NULL) : void  { @@ -40,8 +41,14 @@ function serveResource(string $uri, ?string $filename = NULL) : void      if (!$f)          exit; +    $cachelen = 86400; // secs, 24-hours +    $cachedate = gmdate("D, d M Y H:i:s", time() + $cachelen); +      header("Content-Type: " . mime_content_type($uri));      header("Content-Length: " . filesize($uri)); +    header("Expires: " . $cachedate); +    header("Cache-Control: max-age=" . $cachelen); +    header("Pragma: cache");      if ($filename)          header("Content-Disposition: attachment; filename=\"" . $filename . "\""); | 
