From bbe2b1dc462dd0dd7331b2426bb7b6be2c90c908 Mon Sep 17 00:00:00 2001 From: Shish Date: Sat, 22 Sep 2012 23:10:29 +0100 Subject: [PATCH] don't need to load the file into memory if we're responding with '304 not modified'... --- ext/image/main.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/image/main.php b/ext/image/main.php index f4650626..be28faed 100644 --- a/ext/image/main.php +++ b/ext/image/main.php @@ -365,8 +365,6 @@ class ImageIO extends Extension { $file = $image->get_image_filename(); } - $page->set_data(file_get_contents($file)); - if(isset($_SERVER["HTTP_IF_MODIFIED_SINCE"])) { $if_modified_since = preg_replace('/;.*$/', '', $_SERVER["HTTP_IF_MODIFIED_SINCE"]); } @@ -377,9 +375,11 @@ class ImageIO extends Extension { if($if_modified_since == $gmdate_mod) { $page->add_http_header("HTTP/1.0 304 Not Modified",3); + $page->set_data(""); } else { $page->add_http_header("Last-Modified: $gmdate_mod"); + $page->set_data(file_get_contents($file)); if ( $config->get_int("image_expires") ) { $expires = date(DATE_RFC1123, time() + $config->get_int("image_expires"));