I have a php dynamically generated image which I need to write to file to call later. My problem is that I need this image to have appropriate expiration headers included in it. There are a massive number of these and their headers vary individually file-by-file making .htaccess controls not an option.
I can write expiration headers if I'm outputting the image directly to the browser with this: header("Content-Type: image/jpeg"); header('Expires: "' . gmdate("D, d M Y H:i:s", $expirationDate) . '"'); imagepng($image, NULL);
Or I can write the image to a file to be used later with this: imagepng($image, $filepath)
But I can't for the life of me figure out how to combine those two and write the image to a file while including its expiration headers. How would you go about writing an image file with an expires header?