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.

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.