don't need to load the file into memory if we're responding with '304 not modified'...

This commit is contained in:
Shish 2012-09-22 23:10:29 +01:00
parent 5c30eab6ad
commit bbe2b1dc46

View file

@ -365,8 +365,6 @@ class ImageIO extends Extension {
$file = $image->get_image_filename(); $file = $image->get_image_filename();
} }
$page->set_data(file_get_contents($file));
if(isset($_SERVER["HTTP_IF_MODIFIED_SINCE"])) { if(isset($_SERVER["HTTP_IF_MODIFIED_SINCE"])) {
$if_modified_since = preg_replace('/;.*$/', '', $_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) { if($if_modified_since == $gmdate_mod) {
$page->add_http_header("HTTP/1.0 304 Not Modified",3); $page->add_http_header("HTTP/1.0 304 Not Modified",3);
$page->set_data("");
} }
else { else {
$page->add_http_header("Last-Modified: $gmdate_mod"); $page->add_http_header("Last-Modified: $gmdate_mod");
$page->set_data(file_get_contents($file));
if ( $config->get_int("image_expires") ) { if ( $config->get_int("image_expires") ) {
$expires = date(DATE_RFC1123, time() + $config->get_int("image_expires")); $expires = date(DATE_RFC1123, time() + $config->get_int("image_expires"));