How to set Cache-Control for images? Part two

Hello everyone,

This is about a Grav installation on Linux.

Linux VM unter Proxmox 8.4.14, Ddebian 12 (Bookworm) Kernel 6.8.12-15-pve

Speicher 6.00 GB, Sawp 1.00 GB, 4 Kerne, Disk 64GB

disk usage ca. 8.6%, Speicher ca. 4.4% und CPU ca. 0.1%

PHP 8.4.14 (cli) (built: Oct 27 2025 21:22:56) (NTS)

nginx version: nginx/1.29.3

I assume that nothing has changed since the statements made in August 2018, “How to set Cache-Control for images?”

Ich stolpere gerade über die Aussage von „Pingdom Website Speed Test“ → Web pages are becoming increasingly complex with more scripts, style sheets, images, and Flash on them. A first-time visit to a page may require several HTTP requests to load all the components. By using Expires headers these components become cacheable, which avoids unnecessary HTTP requests on subsequent page views. Expires headers are most often associated with images, but they can and should be used on all page components including scripts, style sheets, and Flash.

And indeed → curl -I https://xx-xx.de/images/f/o/t/o/9/foto9847-6894ab9b.webp

HTTP/2 200

server: openresty

date: Wed, 03 Dec 2025 13:45:52 GMT

content-type: image/webp

content-length: 50368

etag: “6905f26c-c4c0”

expires: Thu, 04 Dec 2025 00:30:00 GMT

pragma: public

cache-control: max-age=38648

x-served-by: xx-xx.de

accept-ranges: bytes

And that’s despite the fact that I entered the following in Grav.conf:

location ~* \.(?:css|cur|js|jpeg|gif|htc|ico|webp|png|html|xml|otf|ttf|eot|woff|woff2|svg)$ {

                access_log off;

                expires 30d;

                add_header Pragma "public";

                add_header Cache-Control "public";

                open_file_cache max=3000 inactive=120s;

                open_file_cache_valid 45s;

                open_file_cache_min_uses 2;

                open_file_cache_errors off;

        }