Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

sm3rter's avatar

Caching Images in Redis?

Should I Cache .webp Images in Redis?

I’m working on a Laravel blog and wondering if caching .webp images in Redis is a good practice. Would this improve performance, or should I rely on browser caching instead?

0 likes
4 replies
Jsanwo64's avatar

Use Cloudinary and cache the images using it.

Jsanwo64's avatar

and to use redis, here is a sample code

JussiMannisto's avatar

I'd serve them normally or use a CDN.

I doubt reading images from a disk is a performance bottleneck in most applications. Operating systems already have an in-memory cache (page cache) for frequently accessed files.

While you technically could implement image caching via Redis, it would only help if you served the images in a way that allowed browsers to cache them. At best, you'd be replacing a single disk read with a Redis query per image per client. Compared to a CDN, you'd have to serve the images from a centralized location, and you'd be bloating your RAM usage.

But if you feel like experimenting, go ahead. Just remember: images have to be cacheable by the browser. Otherwise, you'd be constantly pulling large amounts of binary data from Redis and sending it over the network, which would be way worse than the default.

Please or to participate in this conversation.