Why doesn't GraphQL caching work?

Hi folks!

I have recently found Directus, and so far, I absolutely love it! I currently run it on my own desktop using Docker and have been trying to make a small project with it, just to see how it works, and just experimenting with it.

Right now, I am trying to get GraphQL working, however, since the computer I run Directus on is quite slow, I have tried to get the cache working with Redis. I noticed that the times do not decrease after the first request of data, so it seems that the results are not cached. Does anyone know why this is? I set up Directus up with these environment variables in the Docker Compose file, which also has the Redis server in it:

CACHE_ENABLED=true
CACHE_STORE=redis
CACHE_TTL=5m
CACHE_AUTO_PURGE=true
CACHE_SCHEMA=true
REDIS_ENABLED=true
REDIS_HOST=redis
REDIS_PORT=6379

Could someone please help me out?

Hi guys, got the answer to my issue! As I ran this on a machine that was not my laptop, but my desktop (kind of my “homelab”), I used the locally set domain of “homelab.local”. In my Directus logs, I saw that it only took 40-100ms for a POST /graphql response, however, on my Astro app I noticed it took multiple seconds.

Turns out, because I set the domain in the SDK to this homelab.local instead of the actual IP address, it took a while to figure out that the domain was actually local instead of external, and it got confused. This is why it seemed like it didn’t cache properly.

My apologies!

Thank you for sharing the answer with us, glad you got it figured out! Let us know how your project turns out and if you have any other questions along the way :slight_smile: