Caching

What is cached, how long, and how to purge it.

The fastest request is the one your origin never sees. The edge keeps shareable responses from your functions and serves them without waking your app.

What is cached

A response is cached only when your application says it may be shared. Vantrex does not guess.

Cached Never cached
200, 301, 308, 404 and 410 with s-maxage, or public with max-age 5xx, 302 and any other status
GET (and HEAD, answered from a GET) POST and other methods, and requests with Authorization
Bodies up to 2 MB Responses with Set-Cookie, private, no-store or no-cache

Static files from your build are already immutable and are served directly.

Freshness

  • Stale while revalidate. After a copy expires it is still served briefly while one background request fetches a fresh one.
  • Stale if error. If your app is down or answers with a server error, a recent cached copy keeps answering.
  • Concurrent misses for one page make a single request to your app.
  • A deploy, promote or rollback never serves content from another deployment.

Reading the cache

Every response carries Cache-Status and Age headers that show what the cache did:

curl -sI https://example.com/pricing | grep -i -E "cache-status|age"

Tags and purging

Label responses with Cache-Tag, Surrogate-Key or, from Next.js, x-next-cache-tags. You can then invalidate by tag, by path, or everything for a project.

POST /v1/projects/{id}/cache/purge
{ "tags": ["posts"] }
{ "paths": ["/blog"], "host": "site.example.com" }
{ "all": true }

The request needs an API token with the projects:write scope. Create one under Account, Tokens. A purge reaches the edge within seconds.

Note Caching is switched on per project. If you want it for yours, ask in the dashboard or contact us.