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

wheeler's avatar

intervention/image vs league/glide with cloud caching

I have become a big fan of on-the-fly image resizing and cropping with throwaway caching. It allows me to simultaneously reduce the overall media footprint and maintain flexibility for changing UI requirements.

I've had a long look at URL based manipulation using intervention/image or league/glide.

To me, they both have some flaws when we are talking about high traffic scenarios dealing with thousands of requests in a short period time (the creators admit as much).

The is because for obvious reasons, PHP has to get involved to test whether a cached version is available, vs just returning an image directly from the web server, or better yet, a CDN. Although I haven't put this to the test, I really can't see performance being great when every single image request for all time must go via Laravel.

Intervention supports caching via Laravel Cache, I may be wrong but I can't see a viable way of scaling up when dealing with hundreds of GBs of images.

Glide is a little better on the scaling side in that it supports any Filesystem adapter, but in practice this is actually worse if the server first must first ask Rackspace/Amazon whether a cached file exists then piping the result back, and the roundtrip involved in that.

Glide is effectively putting a hard requirement on using Laravel on every request because of the URL parameter method it uses, whereas Intervention supports a nifty template method without url params.

I think the ideal implementation looks something like this:

  1. cached images have to be saved in a format without url params
  2. the app needs to be able to determine if a cached image exists, whether it be using a cache driver or the db
  3. assuming a cached version exists, the app can then return a CDN or local URL to that file which circumvents the need to call PHP

Has anyone crossed this bridge with either Intervention or Glide? Did you loosely follow this approach or do something different?

Is there a better package out there that solves all this?

0 likes
3 replies
reinink's avatar

Hey! So, as the author of Glide, I'd say you're correct. Handling image requests in extremely high demand situations with PHP is not ideal. Now, I think you may be surprised at what you can get away with (I've seen Glide used in some pretty heavy situations), however I've always said it's not going to be perfect for every situation. I designed Glide for "smaller" projects. Now, that definition is an interesting one, because it probably covers 95% or more of projects.

If I was working on a site that had much more intense image manipulation requirements, I'd probably outsource to Imgix. If I was to do it myself, I'd save all the original upload images, and then use a background job to create the manipulations I required, and then save them to Amazon S3 or another place that they can be served via CDN.

Good luck! :)

4 likes
wheeler's avatar

Yeah I guess out of the box you are right; on the other hand, I am encouraged by the fact that I have already solved this in another project, just that I don't want to go down that particular path again.

In that setup, I built a HTTP adapter for Flysystem with some added image manipulation methods which sits on the app servers, and then a Lumen API backed by Intervention on a high capacity dedicated media server which runs image manipulation (it also does video encoding). I used IP whitelisting rather than signatures, and all requests were generated by the app anyway, no user input.

It works well because running a PHP operation is the last resort and it only ever runs once, immediately after the initial upload. If I change the sizing params, the first few requests are a bit slow with 30+ images per page, but the local cache warms up pretty quick and the CDN is not far behind.

I think the way forward is to use Intervention filter URLs, use memcache for the short lived cache, and add the CDN storage logic into a background queue.

Thanks for your input!

1 like
mkarnicki's avatar

I know this thread is 1 year old, but I found no other interesting source that attempted to reach into Intervention and Glide comparison. @wheeler , can you share your experiences, if any new, regarding those libraries? Have you tried both, or Intervention only? Are you happy with it? Thanks.

EDIT: I just realised "Glide leverages powerful libraries like Intervention Image"... Anyway, any new thoughts :)? Am I comparing apples to oranges here then :)?

Please or to participate in this conversation.