Image Proxy
Proxy endpoint for fetching and optimizing images with support for resizing, format conversion (WebP/AVIF), and quality adjustment.Endpoint
Authentication
No authentication required.Query Parameters
The URL of the image to proxy and optimize. Must be a valid HTTP/HTTPS URL.
Target width for the image in pixels. When set to
0 or omitted, the original width is preserved.The image is resized maintaining aspect ratio.Image quality from 1 to 100.
1: Lowest quality, smallest file size100: Highest quality, largest file size
Output image format:
webp: WebP format (default, good compression and browser support)avif: AVIF format (better compression, newer format)
Response
Success Response
Status Code:200 OK
Headers:
MIME type of the optimized image:
image/webpfor WebP formatimage/aviffor AVIF format
Size of the optimized image in bytes.
Set to
public, max-age=31536000, immutable for aggressive caching (1 year).Error Response
Status Code:400 Bad Request, 404 Not Found, or 500 Internal Server Error
Examples
Caching
The image proxy implements a multi-level caching strategy:- Server-side Cache (Redis): Optimized images are cached for 24 hours with a key based on URL and optimization parameters
- Request Deduplication: Concurrent requests for the same image are deduplicated to prevent redundant processing
- Browser Cache:
Cache-Controlheader set to 1 year for immutable resources - Timeout Protection: 20-second timeout prevents hanging requests
Changing any query parameter (
url, w, q, format) creates a new cache entry, allowing multiple optimized versions of the same source image.Performance Optimization Tips
Use Cases
- Image Optimization: Reduce bandwidth and improve page load times
- Responsive Images: Generate multiple sizes from a single source
- Format Modernization: Convert legacy formats to modern WebP/AVIF
- Thumbnail Generation: Create thumbnails on-the-fly
- CORS Bypass: Access images from domains with restrictive CORS policies
- CDN Alternative: Cache and serve optimized images without a separate CDN
Related Endpoints
- Video Proxy - Proxy video content
- Upload Image - Upload images to the platform
