/** * Create the image HTTP headers * * @param * string path to the file to server (either default or cached version) */ private function _create_headers($file_data) { // Create the required header vars $last_modified = gmdate('D, d M Y H:i:s', filemtime($file_data)) . ' GMT'; $filesystem = new \Illuminate\Filesystem\Filesystem(); $content_type = $filesystem->mimeType($file_data); // $content_type = \Illuminate\Filesystem\Filesystem::mimeType($file_data); $content_length = filesize($file_data); $expires = gmdate('D, d M Y H:i:s', time() + $this->config['cache_expire']) . ' GMT'; $max_age = 'max-age=' . $this->config['cache_expire'] . ', public'; // Some required headers header("Last-Modified: {$last_modified}"); header("Content-Type: {$content_type}"); header("Content-Length: {$content_length}"); // How long to hold in the browser cache header("Expires: {$expires}"); /** * Public in the Cache-Control lets proxies know that it is okay to * cache this content. * If this is being served over HTTPS, there may be * sensitive content and therefore should probably not be cached by * proxy servers. */ header("Cache-Control: {$max_age}"); // Set the 304 Not Modified if required $this->_modified_headers($last_modified); /** * The "Connection: close" header allows us to serve the file and let * the browser finish processing the script so we can do extra work * without making the user wait. * This header must come last or the file * size will not properly work for images in the browser's cache */ header("Connection: close"); }