Image expire time
- by Jens
The google page speed tool recommends me to set 'Expires' headers for images etc. But what is the most efficient way to set an Expires header for an image?
In now redirect all image requests to an imagehandler.php using htaccess:
/*
HTTP/1.1 404 Not Found, HTTP/1.1 400 Bad Request and content type detection stuff
...
*/
header( "Content-Type: " . $content_type );
header( "Cache-Control: public" );
header( "Last-Modified: ".gmdate("D, d M Y H:i:s", filemtime($path))." GMT");
header( "Expires: ". date("r",time() + (60*60*24*30)));
readfile( $path );
But of course this adds extra loading time for my images on first request, and I was wondering if there was a better solution for this.