Jump to content

Re: readFile - Image Caching on client side [split]


Vector

Recommended Posts

Hey, i'm glad to see that someone got this working. Any chance you could take a look at mine? I echoed apache_request_headers() and $_SERVER['HTTP_IF_MODIFIED_SINCE'], but the $_SERVER version is empty each time, and the apache_request_headers does not have the if-modified-since. I send these headers on the initial download, and if you click download again, there is no caching or last-modified. I also used tamper-data to watch the headers being sent (and received), and when the server is sending the headers, it is NOT sending the cache headers.

 

 

I'm kind of desperate to get this working because i'm server VERY large image files, and mp3s, for a band who's on my servers, and fairly popular; which means that i'm about to get all of my bandwidth eaten.:

$expires = 60*60*24*365;
$size = filesize("{$client_directory}/{$_GET['did']}");
header("Content-Length: ".$size,true);
header("Cache-Control: max-age={$expires}, public, no-transform",true);
header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT',true);
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()-$expires) . ' GMT',true);
header("Content-type: audio/example");
header("Content-Disposition: attachment; filename=\"{$_GET['did']}\"");
readfile("{$client_directory}/{$_GET['did']}");

Any help is appreciated.

 

Hi Vector,

 

Please do not resurrect old threads.  This thread is more than a year old (November 07, 2008).  If you would like to create a new thread with your question it would result in better feedback and we will be happy to help

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.