Caching Issues with Directus Backend

What is the name of the domain?

cms.lupinum.com

What is the issue you’re encountering

Images served from my Directus backend through Cloudflare are not being cached properly, despite cache settings being configured. Images are served from Cloudflare R2 S3 Storage through a Directus backend on a Hetzner Cloud server, managed by Coolify.

What steps have you taken to resolve the issue?

  1. Set up Cloudflare caching rules for URLs containing “/assets/” and wildcard “.avif
  2. Configured:
    Edge TTL: Ignore cache-control header and use this TTL → TTL 1 Month
    Browser TTL: Override origin and use this TTL → TTL 1 Month
  3. Set Browser Cache TTL to 4 hours in Cloudflare settings
  4. Enabled all 10 Basic Features in Cloudflare
  5. Checked response headers using Firefox and curl
  6. Deployed a test site on another URL (https://lupinum.at/) to troubleshoot.

What are the steps to reproduce the issue?

  1. Visit https://lupinum.at/
  2. Inspect any image loaded from cms.lupinum.com
  3. Check the response headers of the image, for me, there is no Cloudflare header.

Response Headers

Firefox

HTTP/2 200 
accept-ranges: bytes
alt-svc: h3=":443"; ma=2592000
cache-control: public, max-age=2592000
content-disposition: inline; filename="shadow-overlay-top-view-ipad-pro-and-iphone-13-pro-on-stone-ground-mockup-template-66c321f49e85387ad0858abf-@2x.png"
content-security-policy: default-src none
content-type: image/avif
date: Thu, 22 Aug 2024 16:28:48 GMT
last-modified: Thu, 22 Aug 2024 10:47:48 GMT
vary: Origin, Cache-Control
x-powered-by: Directus
content-length: 544952
X-Firefox-Spdy: h2

Curl

curl -v https://cms.lupinum.com/assets/4484fda0-67ce-43a7-b00a-d909f6ee3416.avif?key=2xl

*   Trying 37.27.203.200:443...
* Connected to cms.lupinum.com (37.27.203.200) port 443
* ALPN: curl offers h2,http/1.1
* (304) (OUT), TLS handshake, Client hello (1):
*  CAfile: /etc/ssl/cert.pem
*  CApath: none
* (304) (IN), TLS handshake, Server hello (2):
* (304) (IN), TLS handshake, Unknown (8):
* (304) (IN), TLS handshake, Certificate (11):
* (304) (IN), TLS handshake, CERT verify (15):
* (304) (IN), TLS handshake, Finished (20):
* (304) (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / AEAD-CHACHA20-POLY1305-SHA256
* ALPN: server accepted h2
* Server certificate:
*  subject: CN=cms.lupinum.com
*  start date: Aug 22 09:45:25 2024 GMT
*  expire date: Nov 20 09:45:24 2024 GMT
*  subjectAltName: host "cms.lupinum.com" matched cert's "cms.lupinum.com"
*  issuer: C=US; O=Let's Encrypt; CN=E5
*  SSL certificate verify ok.
* using HTTP/2
* [HTTP/2] [1] OPENED stream for https://cms.lupinum.com/assets/4484fda0-67ce-43a7-b00a-d909f6ee3416.avif?key=2xl
* [HTTP/2] [1] [:method: GET]
* [HTTP/2] [1] [:scheme: https]
* [HTTP/2] [1] [:authority: cms.lupinum.com]
* [HTTP/2] [1] [:path: /assets/4484fda0-67ce-43a7-b00a-d909f6ee3416.avif?key=2xl]
* [HTTP/2] [1] [user-agent: curl/8.4.0]
* [HTTP/2] [1] [accept: */*]
> GET /assets/4484fda0-67ce-43a7-b00a-d909f6ee3416.avif?key=2xl HTTP/2
> Host: cms.lupinum.com
> User-Agent: curl/8.4.0
> Accept: */*
>
< HTTP/2 200
< accept-ranges: bytes
< alt-svc: h3=":443"; ma=2592000
< cache-control: public, max-age=2592000
< content-disposition: inline; filename="macbook-pro-mockup-w-magic-mouse-66c31fc69e85387ad0858ab5-@2x.png"
< content-security-policy: default-src none
< content-type: image/avif
< date: Thu, 22 Aug 2024 16:14:47 GMT
< last-modified: Thu, 22 Aug 2024 10:47:53 GMT
< vary: Origin, Cache-Control
< x-powered-by: Directus
< content-length: 495993
<
Warning: Binary output can mess up your terminal. Use "--output -" to tell
Warning: curl to output it to your terminal anyway, or consider "--output
Warning: <FILE>" to save to a file.
* Failure writing output to destination
* Connection #0 to host cms.lupinum.com left intact

I would be very grateful if someone could help me solve this problem. Any assistance greatly appreciated.

Many thanks in advance,
Matthias

The solution was simply just to wait longer, now everything is caching properly

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.