Headers for PNG image output to make sure it gets cached at browser? Headers for PNG image output to make sure it gets cached at browser? php php

Headers for PNG image output to make sure it gets cached at browser?


The final thing that worked was:

header('Pragma: public');header('Cache-Control: max-age=86400');header('Expires: '. gmdate('D, d M Y H:i:s \G\M\T', time() + 86400));header('Content-Type: image/png');

Now the browser does not make requests for the image when loading a page with embeded one.


Make sure you also add public as so:

header('Cache-Control: max-age=86400, public');

Read this also, is very helpful.


An Expires header should help.

header('Expires: '. gmdate('D, d M Y H:i:s \G\M\T', time() + 86400));