diff options
author | Cash Costello <cash.costello@gmail.com> | 2009-10-03 19:26:12 +0000 |
---|---|---|
committer | Cash Costello <cash.costello@gmail.com> | 2009-10-03 19:26:12 +0000 |
commit | 9b3cba566de0bc5740e48f3f50eb8b09ffad49dc (patch) | |
tree | 13d8925fb44ef24782a6a211642637ee43431e89 | |
parent | a587ad4ed1867743ea9e698f98a156f4f763e86a (diff) | |
download | elgg-9b3cba566de0bc5740e48f3f50eb8b09ffad49dc.tar.gz elgg-9b3cba566de0bc5740e48f3f50eb8b09ffad49dc.tar.bz2 |
allowing browser to cache photos now
-rw-r--r-- | actions/download.php | 17 | ||||
-rw-r--r-- | thumbnail.php | 13 |
2 files changed, 25 insertions, 5 deletions
diff --git a/actions/download.php b/actions/download.php index 0f9835e11..b382c56bc 100644 --- a/actions/download.php +++ b/actions/download.php @@ -16,7 +16,7 @@ $filename = $file->originalfilename;
$mime = $file->mimetype;
- header("Content-type: $mime");
+ header("Content-Type: $mime");
if ($view == "inline")
header("Content-Disposition: inline; filename=\"$filename\"");
else
@@ -28,10 +28,21 @@ $contents = $readfile->grabFile();
- if (empty($contents))
+ if (empty($contents)) {
echo file_get_contents(dirname(dirname(__FILE__)) . "/graphics/image_error_large.png" );
- else
+ } else {
+
+ // expires every 60 days
+ $expires = 60 * 60*60*24;
+
+ header("Content-Length: " . strlen($contents));
+ header("Cache-Control: public", true);
+ header("Pragma: public", true);
+ header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT', true);
+
+
echo $contents;
+ }
exit;
}
diff --git a/thumbnail.php b/thumbnail.php index eaca0849f..f310aee95 100644 --- a/thumbnail.php +++ b/thumbnail.php @@ -60,10 +60,19 @@ if (!$contents) {
forward('mod/tidypics/graphics/' . $error_image);
}
+
+ // expires every 14 days
+ $expires = 14 * 60*60*24;
- // Return the thumbnail and exit
+ // overwrite header caused by php session code so images can be cached
$mime = $file->getMimeType();
- header("Content-type: $mime");
+ header("Content-Type: $mime");
+ header("Content-Length: " . strlen($contents));
+ header("Cache-Control: public", true);
+ header("Pragma: public", true);
+ header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT', true);
+
+ // Return the thumbnail and exit
echo $contents;
exit;
?>
|