Cached API responses are now free and edge-served
March 31, 2020
Starting today, any Microlink API response served from the cache no longer counts toward your API quota. Cached responses are also served from the CloudFlare Network, and screenshots get lossless compression and WebP on the fly.
TL;DR
- Responses served from the cache no longer count toward your API quota.
- An
og:imagetag on a page with 1000 pageviews used to consume 1000 requests. Now it consumes one. - Cached responses come from the CloudFlare Network, the nearest of more than 240 edge servers in over 90 countries.
- Screenshots get lossless compression on the fly, and WebP when the browser supports it, which can decrease average image size up to 42%.
Microlink API has shipped with a built-in cache layer from the beginning, to speed up consecutive calls for the same resource. This release reworks that layer in three ways: what it costs, where it is served from, and what it does to images.
The first time you query a resource that was not served before, such as a screenshot of
https://example.com, the API generates it. That is a cache MISS. Every successive request for the same resource returns the cached version, a cache HIT, and hits are the part this release changes.Cache hits no longer count toward your quota
npx microlink.io screenshot https://example.comAny response served from the cache won't count towards your API quota. That changes how you can use the API, and the clearest case is embed: pointing your HTML markup straight at an API URL.
<meta name="og:image" content="https://api.microlink.io?url=https://example.com&screenshot&embed=screenshot.url">A screenshot generated on the fly, always up to date.
Before, if your website had 1000 pageviews with this tag, you consumed 1000 requests from your API quota.
Now you consume *one request*. The rest are served from the cache and don't count toward your API quota plan.
Cached responses come from the nearest edge server
The CloudFlare Network has more than 240 edge servers in over 90 countries.
The first request for a resource is answered by one of our origin servers, wherever it is located. Once cached, every successive request for that resource is served through the CloudFlare Network, from the nearest of more than 240 edge servers in over 90 countries.
Cached response (blue) vs. Uncached response (gray).
In the chart, the cached response (blue) always has a lower response time than the uncached one (gray), no matter where you are, because it never leaves the CloudFlare edge.
Screenshots are compressed and served as WebP
WebP browser adoption.
Microlink screenshot is one of the most used features: we serve around 100K fresh screenshots every day, generated in an average of ~1.5 seconds. We host every image generated, and the cache now optimizes it on the way out:
- Lossless compression on the fly: the image is identical to the original, with fewer bytes.
- WebP when the browser supports it: most modern browsers do, and WebP can decrease up to 42% in average image size.
Try it
Run
npx microlink.io screenshot https://example.com twice. The first call is a MISS and counts toward your quota. The second is a HIT from the nearest edge server and is free. Read the embed docs to put the same screenshot URL in your og:image tag.Join the community
All of these improvements or features are community driven: We listen to your feedback and act accordingly.
Whether you are building a product, an indie developer, or just interested in web technologies, come chat with us.