diff --git a/CImage.php b/CImage.php index cc0bf26..8693f9a 100644 --- a/CImage.php +++ b/CImage.php @@ -275,9 +275,12 @@ EOD; $info = list($width, $height, $type, $attr) = getimagesize($file); !empty($info) or $this->RaiseError("The file doesn't seem to be an image."); $mime = $info['mime']; - $time = filemtime($file); + $lastModified = filemtime($file); + $gmdate = gmdate("D, d M Y H:i:s", $lastModified); - if(isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $time){ + if(!$this->verbose) { header('Last-Modified: ' . $gmdate . " GMT"); } + + if(isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $lastModified){ if($this->verbose) { $this->Log("304 not modified"); $this->VerboseOutput(); @@ -285,8 +288,6 @@ EOD; } header("HTTP/1.0 304 Not Modified"); } else { - $gmdate = gmdate("D, d M Y H:i:s", $time); - if($this->verbose) { $this->Log("Last modified: " . $gmdate . " GMT"); $this->VerboseOutput(); @@ -294,7 +295,6 @@ EOD; } header('Content-type: ' . $mime); - header('Last-Modified: ' . $gmdate . " GMT"); readfile($file); } exit; diff --git a/README.md b/README.md index f249dae..82e2768 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,12 @@ Combine the parameters to get the desired behavior and resulting image. For exam Revision history ------------------------------------- +v0.4.x (latest) + +* Changed => to == on Modified-Since. +* Always send Last-Modified-Header. + + v0.4 (2013-10-08) * Improved support for pre-defined sizes. @@ -101,7 +107,8 @@ v0.4 (2013-10-08) * Added usage of all parameters to README.md * Added documentation here http://dbwebb.se/opensource/cimage * Adding `.gitignore` -* Readding `cache` directory +* Re-adding `cache` directory + v0.3 (2012-10-02) diff --git a/img.php b/img.php index 0ade12a..3858295 100644 --- a/img.php +++ b/img.php @@ -24,9 +24,9 @@ set_exception_handler('myExceptionHandler'); // Use preprocessing of images -#define('PNG_FILTER', '/usr/local/bin/optipng -q'); -#define('PNG_DEFLATE', '/usr/local/bin/pngout -q'); -#define('JPEG_OPTIMIZE', '/usr/local/bin/jpegtran -copy none -optimize'); +define('PNG_FILTER', '/usr/local/bin/optipng -q'); +define('PNG_DEFLATE', '/usr/local/bin/pngout -q'); +define('JPEG_OPTIMIZE', '/usr/local/bin/jpegtran -copy none -optimize'); // Append ending slash @@ -151,13 +151,14 @@ else { -// Display image if vebose mode +// Display image if verbose mode if($verbose) { $query = array(); parse_str($_SERVER['QUERY_STRING'], $query); unset($query['verbose']); unset($query['v']); unset($query['nocache']); + unset($query['nc']); $url1 = '?' . http_build_query($query); echo <<$url1
diff --git a/img/kodim15.png b/img/kodim15.png new file mode 100644 index 0000000..9a77b67 Binary files /dev/null and b/img/kodim15.png differ