staleTtlPRO
Type:
Default: false
<string> | <number> | <boolean>
Default: false
It enables serve a stale response while a background refresh cache copy is being generated over the target url.
- CLI
- JavaScript
- Shell
- Python
- Ruby
const mql = require('@microlink/mql')
const { status, data } = await mql('https://microlink.io', {
ttl: '1d',
staleTtl: 0
})
mql.render(data)
The value provided can't be higher than ttl, being supported the following formats:
- as number in milliseconds (e.g., 86400000).
- as humanized representation of the number (e.g., '24h').
The following humanized number variations are supported:
https://microlink.io&staleTtl=1d # 86400000 https://microlink.io&staleTtl=1day # 86400000 https://microlink.io&staleTtl=1days # 86400000 https://microlink.io&staleTtl=1h # 3600000 https://microlink.io&staleTtl=1hour # 3600000 https://microlink.io&staleTtl=1hours # 3600000 https://microlink.io&staleTtl=90s # 90000 https://microlink.io&staleTtl=90secs # 90000 https://microlink.io&staleTtl=90second # 90000 https://microlink.io&staleTtl=90seconds # 90000
A good pattern is to set
staleTtl=0
to always revalidate in the background under expiration, maximizing the cache usage serving the last cache copy generated while the revalidation will refresh it.