Reputation: 913
I'm using php to output an image using readfile
function. I've set the headers for this php file as below:
$expires = 60*60*7;
header('Pragma: public');
header('Expires: '. gmdate('D, d M Y H:i:s \G\M\T', time() + $expires));
header('Content-Type: image/jpeg');
header("Cache-Control: maxage=".$expires);
Both expire
and Cache-Control
headers are set, but each time i load the url, image gets downloaded. Is there any other header rule needed to enable caching?
Upvotes: 1
Views: 138
Reputation: 10610
Use the Content Disposition header:
header("Content-Disposition: inline;filename=something.jpg")
This tells the browser to display it inline (rather than the default attchment, which triggers the download). Attachments will download regardless of cache values.
Upvotes: 1