# Caching

When you check a value, the API stores the result for 7 days. If the same value is checked again in that time, the stored result comes back instead of running the checks again.

## How it works

- **The cache key is a SHA-256 hash** of the normalized input plus the level (phone) or the mode (email). The key is a hash, not the value itself.
- **Levels and modes are cached separately.** A `basic` phone result never answers a `live` request, and a `fast` email result never answers a `full` one.
- **Entries expire after 7 days.** After that, the next request for the value runs the checks again.
- **Every result says where it came from:** `cached: true` when it was served from the cache, `cached: false` when it was computed for this request.

Some results are never cached, so the next request always runs the checks again:

- email results with a temporary reason: `greylisted`, `smtp_timeout`, `smtp_blocked`, `smtp_unavailable` and `dns_error`;
- results that were not billed;
- results returned to test keys;
- the rows of [bulk jobs](/docs/api-reference/bulk), which are always checked afresh.

## What the cache is for

- **Speed.** A cached email result does not wait for a mail server, and a cached live phone result does not wait for the upstream provider.
- **Consistency.** Two services that check the same value a minute apart get the same answer.
- **Fewer probes of mail servers.** Checking the same mailbox again and again is the kind of traffic that mail servers greylist or block. Answering repeats from the cache keeps the mailbox check working.

## Cached results cost the same

A cached result costs the same credits as a fresh one. You pay for the answer, not for the work behind it. If you check the same value often, store the result with your own record and reuse it: that is the only way not to pay again. See [Credits](/docs/credits).

## Bypass the cache with fresh

Send `"fresh": true` to run the checks again instead of reading the cache:

```bash
curl https://api.qelka.com/v1/email \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"email": "jane@example.com", "fresh": true}'
```

`fresh` works the same on `/phone`, `/email`, `/ip` and on each item of a [batch](/docs/api-reference/batch). It costs the same as any other call.

Good reasons to send it:

- **The user just changed something.** They created the mailbox, fixed their domain's MX records, or moved their number to another carrier.
- **A dispute.** A customer says an address you rejected works. Check again with `fresh: true` before you answer.

You do not need it to retry an email that came back `unknown` because of greylisting, a timeout or a DNS failure: those results are not cached. Wait a while before you retry, though. Greylisting (RFC 6647) works by refusing the first attempt and accepting a retry that comes minutes later, not seconds.

Bad reasons: sending `fresh: true` on every call. It makes every check slower and puts more load on the mail servers you depend on, for the same price.

## Privacy

Cache keys are SHA-256 hashes of the input, and every entry expires after 7 days. A cached entry holds the result, which includes the `input` you sent, until it expires. Emails and phone numbers are never written to logs in plain text. [Data and privacy](/docs/data-and-privacy) describes everything we keep and for how long.
