# Caching and max_age

> The shared result cache, its default window per data type, how max_age overrides it, and how to tell a cached result from a fresh one.

When a request matches one we fetched recently, we can answer from a shared cache instead of fetching again. Every response says when its data was fetched, so a cached answer is never presented as a fresh one.

## Default windows

| Data | Default window | Why |
|---|---|---|
| Google and Bing organic SERP, standard queue | 6 hours | Daily rank tracking at scattered hours still gets a same-day ranking. |
| Google and Bing organic SERP, priority queue | 1 hour | Priority pays for freshness. |
| Google and Bing organic SERP, live | none | Live means fresh. |
| Google Maps SERP | Same as organic for each mode: 6 hours, 1 hour, none | |
| `my_business_info`, products, photos | 24 hours, in every mode | Profiles change rarely. |
| Meta ads, Yelp ads | 6 hours | Ad sets change slowly within a day. |
| `instant_pages`, `content_parsing`, Crawl API pages | none | You usually check a page right after changing it. |
| `llm_responses` | none | Each answer is a sample; tracking needs fresh draws. |

## What counts as the same request

The cache key is built from the normalized query only, and holds no customer data, so it's shared across customers:

- **SERP:** engine, search type, keyword, location, language, device, OS and depth (rounded to a whole results page).
- **Business profile:** the place identifier or keyword, language, country and `location_name`.
- **Products:** the place CID and `hl`.
- **Photos:** each query, `tag`, `language` and `region`.
- **Ads:** the search terms, page ids, countries, ad type, active status and how many results you asked for.

## max_age

Send `max_age` (whole seconds, 0 to 86,400) on any task to replace the default window for that task:

```json
[{ "keyword": "trail running shoes", "location_code": 2840, "language_code": "en", "max_age": 0 }]
```

- `max_age: 0` always fetches fresh.
- `max_age: 3600` accepts a result up to 1 hour old, even on a live request.
- Values outside 0 to 86,400, or not a whole number, fail the task with `40501`.

`max_age` doesn't apply to endpoints that don't cache (Pages, Crawl API, `llm_responses`).

## Telling cached from fresh

| Field | Where | Meaning |
|---|---|---|
| `cache_hit` | Every task, and `request_info` / the envelope on other shapes | `true` when the result came from the cache. |
| `fetched_at` | In `result`, ISO 8601 | When the data was actually fetched. On a cache hit, that's the original fetch time. |
| `datetime` | In `result`, DataForSEO format | Also the original fetch time on SERP results. |

## Billing

A cached result is billed at the endpoint's normal list price for the mode you called, the same as a fresh one. A cached result that holds no data (for example a place with no products) costs $0.

> **Tip:** For scheduled rank tracking, the standard queue with its 6-hour window is usually what you want. Use `max_age: 0` only where same-hour freshness changes a decision.
