aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--actions/download.php17
-rw-r--r--thumbnail.php13
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;
?>