Vector Posted November 23, 2009 Share Posted November 23, 2009 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 serving 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 https://forums.phpfreaks.com/topic/182696-caching-of-files-served-by-readfile-headers-not-being-sent/ Share on other sites More sharing options...
Vector Posted November 23, 2009 Author Share Posted November 23, 2009 Ok, i've got it sending the CORRECT cache headers now, but i am still not getting the "if-modified-since" header from the client. Here's the client headers: Host=ionisis.com User-Agent=Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.15) Gecko/2009102704 Fedora/3.0.15-1.fc10 Firefox/3.0.15 Accept=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language=en-us,en;q=0.5 Accept-Encoding=gzip,deflate Accept-Charset=ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive=300 Connection=keep-alive Referer=http://violentworkofart.test/?a=WCMS_Page_Display&id=156008001258174118&t=6_-_C.O.M.A. Cookie=sssssssssssssssssssssssssssssss and the server headers: Status=OK - 200 Date=Mon, 23 Nov 2009 23:27:18 GMT Server=Apache/2.2.11 (Fedora) Content-Length=4400274 Cache-Control=max-age=31536000, public, no-transform Expires=Tue, 23 Nov 2010 23:26:09 GMT Last-Modified=Mon, 23 Nov 2009 23:26:09 GMT Content-Disposition=attachment; filename="Coma.mp3" Content-Encoding=gzip Vary=Accept-Encoding Keep-Alive=timeout=15, max=100 Connection=Keep-Alive Content-Type=audio/example But when i request the file over and over, the headers are the same. The client never sends the "if-modified-since" header, and so i can't tell if they've already downloaded it before so that i can send them the "not modified" header, instead of the file. Link to comment https://forums.phpfreaks.com/topic/182696-caching-of-files-served-by-readfile-headers-not-being-sent/#findComment-964374 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.