Cache TTL: A configurable cache, served from the edge
Don't pay to re-render the same screenshot or PDF twice. Every cache HIT is free — across every Microlink output. Use ttl to set the freshness window and staleTtl to keep callers instant during the background refresh.
With staleTtl, even revalidations happen in the background.
One paid MISS warms the cache; every HIT until ttl expires is free — including expensive screenshot and PDF renders.
Two caches behind it: a unified cache (x-cache-status) holds the shared copy per URL; a CloudFlare edge cache (cf-cache-status) serves it from the nearest of +330 edge nodes. Cold regions auto-populate from the unified layer.
ttl sets the cache window. staleTtl enables stale-while-revalidate — callers always hit cache while refreshes happen in the background. No Redis, no cron jobs.
Pay once. Serve millions of cache hits for free.
A request cache, an invalidation policy, and a background revalidator are the three pieces every team rebuilds on top of an external API. Pro folds them into the response layer — and cache hits never count against your plan quota, so the better your cache strategy, the less you pay per served request. ttl tunes lifetime, staleTtl covers cold starts, and the response headers expose enough observability to keep your cache hit rate honest.
86400000) or as a humanized string ('1d', '90s', '1hour'). The aliases 'min' and 'max' snap to the boundaries.MISS buys you free hits for the entire cache window. Short TTLs for dashboards and feeds, longer TTLs for marketing pages and docs, and 'max' for content that essentially never changes. The effective lifetime always echoes back as x-cache-ttl.HIT, MISS, or BYPASS; the rest tell you why.Recommended: one paid request per day, the rest are free
Keep responses valid for 24 hours and serve every caller from cache while a background refresh keeps them current. The result: a single billed MISS per cache window, every other request a free HIT. Works the same on metadata, screenshots, PDFs, HTML, and markdown.
import mql from '@microlink/mql'
const { data } = await mql('https://example.com', {
apiKey: process.env.MICROLINK_API_KEY,
ttl: '1d',
staleTtl: 0
})Need a guaranteed fresh response?
Pass force: true to skip the cache layer entirely and force-regenerate a new copy. The response header x-cache-status will read BYPASS, and a fresh entry replaces the previous one. Use it for cache invalidation events — not on every request.
import mql from '@microlink/mql'
const { data } = await mql('https://example.com', {
apiKey: process.env.MICROLINK_API_KEY,
force: true
})How to confirm cache behavior
x-cache-status is the source of truth — and the difference between a free request and a billed one. HIT means served from the unified cache (not counted toward your plan), MISS means a fresh build (billed), and BYPASS means the cache was skipped on purpose (billed). The accompanying cf-cache-status tells you whether CloudFlare's edge served it from a node close to the caller.
Pay for misses. Hits are on us.
Pick the volume that matches your traffic. Cache TTL tuning, stale-while-revalidate, and the cache layer (unified cache + CloudFlare edge) are included on every Pro plan — and every cache hit served from those layers stays free, no matter how many requests it absorbs.
Does caching apply to screenshots and PDFs too?
HIT for free, served from the nearest CloudFlare edge node. Because rendered outputs are the most expensive ones to produce, that is also where caching saves you the most.Do cached responses count against my plan quota?
What is the difference between ttl and staleTtl?
What values can I pass to ttl?
86400000) or a humanized string. Supported units: s, m, h, and d in singular, plural, and long-form variants — for example '90s', '1hour', '7days'.'min' equals 1 minute and 'max' equals 31 days. The minimum is 1 minute and the maximum is 31 days; values outside that window get clamped.How does stale-while-revalidate actually work?
Cache-Control: stale-while-revalidate), implemented inside the API so you do not have to coordinate it on your end.How do I bypass the cache for a fresh response?
How do I confirm cache behavior on a request?
HIT, MISS, or BYPASS) is the source of truth for the unified cache. cf-cache-status reports the CloudFlare edge layer separately.