pngcache-controlweb-optimization

how do you add a "Cache-Control: public" header to a png file?


I've recently been looking at the Safari performance audits/recommendations. One section refers to adding Cache-Control: public header to some png resources.

I've heard that said elsewhere and wondered how it can be done.

In fact I'm not even sure technically speaking what needs to be done to achieve this . Is it that this text is inserted into the image file somehow?


Solution

  • That's an HTTP header; you need to configure your web-server to provide it. (HTML offers a way to specify HTTP-header-equivalents inside a document, but PNG does not.)

    You haven't mentioned what web-server you're using, so it's hard to answer it in general, but for example, if you're using Apache, you can use the "header" directive in mod_headers: http://httpd.apache.org/docs/2.2/mod/mod_headers.html#header