RabbitLoader has a built-in feature to convert and serve images in WebP/AVIF format wherever supported. The conversion to WebP and AVIF happens only if the source file is compatible and the visitor’s browser supports it. In one of our blog posts, we discussed the benefits of using WebP image format.
If you turn off this feature, RabbitLoader will serve images in the same format as coming from Origin. It means, that if the origin is sending an image in PNG format, it will be served in PNG format. Similarly, if the origin is sending an image in JPG format, it will be served in JPG format. And the same applies to all other formats like GIF, BMP, Bitmap, TIFF, etc.
Page Contents
Set up a page rule if not already done to control the image behavior. Setting up page rules gives website owners full control if they want to enable certain features only on a particular segment. If you are new to the page rules, this guide will be very helpful when adding a new page rule.
On the console, go to Settings->Page Rules. Click the ‘Modify’ button on the ‘*’ rule.
In the next step, first, turn on the checkbox for Image optimization and then enable the checkbox for “Convert PNG/JPEG images to WEBP/AVIF format” and save the rule.
Once you save the rule, it may take a few minutes to get effective. However, due to the nature of the Internet, content that is already cached across edge servers will continue to serve the original image files. The rule will get effective for new requests only or after purging the existing cache.
You can create as many rules as you want to separate out the settings for each URL prefix. If you have added more page rules, you can repeat the instructions above for specific page rules instead of the ‘*’ rule. Please make sure the execution sequence of the rules is in the order you expect.
The dimensions of the images converted to the next-gen format by RabbitLoader depend on the screen size of the visitor. Every time an image is served, the dimension of the image is decided based on the visitor’s device. Please note that when image optimization is on, the width of the image will get restricted to a maximum of 1920px with the original aspect ratio maintained.
If the maximum size is a concern for you for some of the images, you may consider one of these options-
rl-resize=0
GET parameter to the image URL (with the appropriate prefix ‘?’ or ‘&’)When RabbitLoader optimizes an image and converts its format, the URL of the images remains the same and does not change. For example, if a website has an image https://example.com/image-hero.jpg
, only the “Content-Type” header changes, and the URL along with the file extension remains the same and will still end with “.jpg” even when RabbitLoader resizes and converted it to the next-gen formats, such as WebP and AVIF.
To verify if images are correctly getting converted, the Content-Type header should be checked. For example, when in Chrome, this is how the type can be checked for all images of a page-
This is a kind of checklist for you. Please note that not all images can be converted to next-gen format. If you find the website not converting images to WebP/AVIF it could be because of one of the below reasons-
example.com
is served from img.othercdn.com
.Vary
‘ header for an image, that contains a “Accept
” value, the conversion does happen because the header indicates that the origin is able to understand the browser’s capabilities and serve the accepted format.