Transparently cache and compress images on the fly.
GET /img
?url=<initial_image_url>
&compress=<mode>
- If the image is not cached yet, it will redirect to the original image while caching it in the background.
- Once a cached image exists, it will serve the cached image.
- If compression is requested, it will compress in the background during the caching phase. Multiple compression modes can be requested for the same image because (image_url,compression_mode) pairs are cached separately.
mode | format | parameters used for compression |
---|---|---|
webp,lossless | webp | -lossless 100 -q 100 -m 6 |
webp,lossy,afq1 | webp | -af -q 1 |
webp,lossy,afq10 | webp | -af -q 10 |
webp,lossy,afq20 | webp | -af -q 20 |
Assuming the cache server is located at https://proxy.com/
Initial image URL: https://blog.hubspot.com/hubfs/image8-2.jpg
Cached only: https://proxy.com/img?url=https://blog.hubspot.com/hubfs/image8-2.jpg
Cached and compressed: https://proxy.com/img?compress=webp,lossless&url=https://blog.hubspot.com/hubfs/image8-2.jpg