Skip to content

Webperf -Add HTTP "Cache-Control: immutable" headers for images files

Added HTTP "Cache-Control: immutable" headers for PNG, JPG and SVG files to use the browser's cache to the maximum.

  • For Firefox, thhe HTTP "Cache-Control: immutable" header will be honored only if the content is served in HTTPS.
  • Chrome does not actually support immutable at the moment, but has its own new heuristics

Documentation

<IfModule mod_headers.c>
    <FilesMatch "\.(png|svg|jpg|jpeg)$">
        Header set Cache-Control "public, max-age=31536000, immutable"
    </FilesMatch>
</IfModule>

Todo list

  • add the timestamp on the software logo
  • add the timestamp on the users logo
  • add timestamp on screenshots
  • refine the apache rule to handle only images from the following directories:
    • /webroot/img/logos
    • /webroot/img/files
  • apply changes in prod (code + Apache configuration)

Edited by Fabrice Gangler