Images.weserv.nl is a an open-source image resizing and caching web API that’s used on millions of webites to optmize, resize and transform images on the fly. The images are served by CloudFlare’s CDN, providing a distributed worldwide cache for performance.
Beginning November 2022 the service was rate limited by a change to CloudFlare’s terms of service. CloudFlare’s new R2 and Images products are the likely reasons why the ToS changed, but regardless it is the cause of the issue and is why your images are loading extremely slow from images.weserv.nl.
Replace images.weserv.nl with wsrv.nl
wsrv.nl seems to be unaffected by the rate limiting. This could change anyday so while it will fix the problem immediately, it’s not a viable long-term solution.
An active discussion can be found in the
weserv/images GitHub repository under issue #360. If you have any trouble using
wsrv.nl this would be the best source of up to date information to refer to.
Host your own API
The software that powers images.weserv.nl is open-source and available on GitHub, so it’s not as difficult as you may think. You don’t need to build your own custom solution, you just need to host and configure your own setup with the project found on GitHub. The host can be connect to a CloudFlare business account so that it doesn’t violate their terms and will not be rate limited. For online businesses that need reliability, and want to continue optimizing images with the same API pattern this is the best choice.
The image processing library used by the service is libvips. It’s very good on memory and is very fast when compared to other alternatives that exist.
CloudFlare ToS Changes
CloudFlare changed their terms of service to support caching of static HTML pages only on their free plans. Images and videos are not allowed anymore, which is why images.weserv.nl is limited. I’m not a lawyer, so this is not to be taken as legal advice in anyway. The specific section of the terms of service includes the following:
The Services are offered primarily as a platform to cache and serve web pages and websites. Unless explicitly included as part of a Paid Service purchased by you, you agree to use the Services solely for the purpose of (i) serving web pages as viewed through a web browser or other functionally equivalent applications, including rendering Hypertext Markup Language (HTML) or other functional equivalents, and (ii) serving web APIs subject to the restrictions set forth in this Section 2.8. Use of the Services for serving video or a disproportionate percentage of pictures, audio files, or other non-HTML content is prohibited, unless purchased separately as part of a Paid Service or expressly allowed under our Supplemental Terms for a specific Service. If we determine you have breached this Section 2.8, we may immediately suspend or restrict your use of the Services, or limit End User access to certain of your resources through the Services.
For more information the full terms can be found in CloudFlare’s ToS Section 2.8: Limitation on Serving Non-HTML Content.