From: Christian Weiske Date: Wed, 9 Apr 2014 18:29:16 +0000 (+0200) Subject: send expiry header for redirects X-Git-Tag: v0.1.0~24 X-Git-Url: https://git.cweiske.de/phancap.git/commitdiff_plain/aff10bd3ebdabe6efe7f1ffdb9df7177c6334135 send expiry header for redirects --- diff --git a/src/phancap/Image.php b/src/phancap/Image.php index ab3868e..151847e 100644 --- a/src/phancap/Image.php +++ b/src/phancap/Image.php @@ -12,6 +12,16 @@ class Image $this->name = $name; } + /** + * @return integer Unix timestamp + */ + public function getExpiryDate(Options $options) + { + $mtime = filemtime($this->getPath()); + + return $mtime + $options->values['smaxage']; + } + public function getMimeType() { $ext = substr($this->name, -4); diff --git a/www/get.php b/www/get.php index 15463e4..739aaf8 100644 --- a/www/get.php +++ b/www/get.php @@ -42,6 +42,7 @@ try { $img = $rep->getImage($options); if ($config->redirect) { header('HTTP/1.0 302 Found'); + header('Expires: ' . date('r', $img->getExpiryDate($options))); header('Location: ' . $img->getUrl()); } else { header('Content-type: ' . $img->getMimeType());