Docs menu
- Docs
- Guides
- Reuse a recent copy
Reuse a recent copy
When anyone fetched the same page with the same settings in the last 5 minutes, you get that copy for the cache price, with X-Cache: hit. Your own transforms (schema, prompt) still run on your request. max_age sets the window: 0 to 900 seconds, 300 when you leave it out. max_age=0 always fetches fresh.
curl -s "https://get.megalania.io/v1?url=https://example.com/pricing&max_age=60" \ -H "Authorization: Bearer $MEG_API_KEY" -D -
How it works
max_age |
what happens |
|---|---|
| left out | Same as 300. |
0 |
We fetch the page fresh and keep a copy. |
1 to 900 |
A copy at most this many seconds old is served. Otherwise we fetch and keep a copy. |
- A copy is the page as our engine fetched it, never another customer’s answer. It holds no account data, so every account can use it.
- A copy matches only the same page fetched the same way: the same URL and
the same parameters that shape the page (
response_types,extract,country_code,only_main_content,wait_until, a chosenengineorproxy_tier, and so on).timeout,max_credits,schemaandpromptdo not count. - A copy lives in memory inside our cluster for at most 15 minutes, and is
never served after
max_age. - We keep a copy only of a page we charged for, with a target status below
500, that was not cut by
max_creditsor a byte cap. Blocked pages, errors, pages fetched with a site session and answers over 2 MiB are not kept. - A request with a
timeoutunder the default 60 s can read a copy, but its own page is never kept: a short timeout can cut the page. - A copy is served only on a route your plan and key may use.
Price
- A hit costs the cache price of your plan, and never more than the fetch it copies cost.
- A
schemaorprompton a hit runs the model on the copy, and you pay the model part as usual. - A miss costs what the page costs. See Credits and pricing.
max_creditsand your balance must cover a live fetch, even when a copy is served: we hold the credits first, then look for a copy, and give back what a hit does not use.
Headers and fields
X-Cache: hitorX-Cache: misson every answer that could use the cache.- A hit repeats
X-Engine,X-RouteandX-Target-Statusof the fetch it copies.X-Request-IdandX-Credits-Chargedare the new ones. - MCP
scrapeandextracttakemax_ageand answer"cache": {"hit": true}. A batch item served from a copy carries the samecacheobject. - We do not say how old a copy is: the copy may come from another account,
and its age would tell you when that account fetched the page. Your
max_ageis the most it can be.
What never uses it
A request with method, body, headers (so cookies and auth headers),
actions, screenshot, network, session_id, or a user name or password
in the URL is always fetched live and never kept. Sending max_age with one
of them is a free 400 bad_parameter naming max_age. A monitor always
fetches fresh and takes no max_age.
Privacy
A copy is stored under a keyed hash of the request, never the URL, and is encrypted. It never appears in logs or tables. See Privacy.