About a year ago, CloudFlare launched Mirage, a service for its paying users that aimed to speed up website loading times by delivering smaller images and using “lazy load” to just download images that actually appeared in the browser’s viewport. Today, the company is almost completely revamping this service based on what it learned from this first version.
As the Cloudflare’s founder and CEO Matthew Prince told me, the first version of Mirage took every image on a site and then created five copies of it in different sizes to match the most often used screen sizes. This worked, but it also meant that the new images often didn’t match the layout of the page or size of the screen perfectly.
To overcome this issue, CloudFlare is using a pretty ingenious trick in Mirage 2.0. Instead of creating multiple copies, it simply creates a highly degraded version of the image that’s often just 1% of the original file size. This image does, however, contain all of the meta data the browser needs to place the image on the page and start rendering the page.
Once the page finishes rendering, CloudFlare’s new Virtualized Image Loader kicks in and starts replacing these images with their full-resolution versions.
The effect, Prince told me, is similar to the old progressive JPEGs you’re probably familiar with if you’ve been on the web long enough. This switch between the two images is the trade-off website owners have to make when they use Mirage. This technique prevents the browser from having to wait for image downloads before it can start rendering the page, which should make the user experience feel significantly faster, but users may be a bit surprised to see these highly degraded images at first.
Here is an example of how much of a difference Mirage could make on our own site (we’re not using it right now, though):
All of this, of course, also works for regular websites, but CloudFlare is specifically aiming this at mobile sites.
Imgur, the popular image host, has been testing this feature on its site and as Alan Schaaf, the company’s founder and CEO told us, Imgur has “seen great improvements with Mirage 2.0. We’re really happy that CloudFlare continues to launch innovative products to ensure pages on Imgur.com load as fast as possible.”
To speed up loading times even more, the Virtualized Image Loader also takes the device’s capabilities and network conditions into account. CloudFlare’s vast network and user base allows it to sample a massive amount of data and can now adjust how aggressive Mirage 2.0 compresses data depending on the network the request is coming from. In order to keep packet loss at a minimum, the service also combines all of these images into one request instead of initiating a new request for every image.
Mirage 2.0 is now available in beta for all paying CloudFlare users, including those with a $20/month pro account. The good folks at CloudFlare, however, also gave us 50 promo codes for free access to the Mirage 2.0 beta, even if you’re just using a free account. If you’re interested – and a CloudFlare user – just head over here to sign up.