What headers should a send with an image output (image.php when opened allows user to download an image) to set caching time for that image to 3 days (instead of re-downloading the image from the user side) ??
and how can i compress the image and send it compressed and what headers should i send along to tell the browser that this image is compressed ?
thank you .
Well, the easiest way to compress is to enabled deflate or gzip from the htaccess level if you’re running apache. If not, you can add the
ob_gzhandler()function as theob_start()callback at the beginning of the document like so:Note this requires the zlib extension.
You can also add this function as the ob callback in the php.ini file or enable the zlib.output_compression directive.
As for setting up caching, simply add this
header()call before outputting text: