I’m setting the background-image of my website to a url on the server, which is a php script and which serves an image as its output. Here is the code for it:
//$mime is usually image/jpeg, etc
header("Content-type: $mime");
$image = readfile($image);
imagejpeg($image);
The issue is, each time I load my page, the image seems to be loaded again rather than being cached. Is there anything I can do about that, e.g to send a header to cache the image?
I always get best results using the ETag (a
md5hash) and Last-Modified (a past date, usually when the file was created).for your code it will be like this: