Jump to content

Cache Control not being set - PHP


Alex-Grim

Recommended Posts

Ok, this is driving me insane. I have no problem on the server level, but when trying to set cache control with PHP it simply will not work for me. I WANT cache, and LOTS of it!

 

$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']}");

 

ALL of the other headers are fine, but the cache control will NOT set??? I've tried so many different ways, and none of them are working. Here are the output headers:

 

Status=OK - 200
Date=Mon, 23 Nov 2009 08:15:19 GMT
Server=Apache/2.2.8 (Fedora)
Content-Length=4400274
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

 

Thanx

Link to comment
https://forums.phpfreaks.com/topic/182610-cache-control-not-being-set-php/
Share on other sites

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.