Skip to main content

Cache and ETag

How to use it

1

Save the ETag

In the first response, read the header ETag.
2

Forward with If-None-Match

In the next identical request, send If-None-Match: <etag>.
3

Receive 304

If nothing changed, the API answers 304 Not Modified without a body. You reuse your local copy.

Example

Cache-Control

The response marks Cache-Control: public, max-age=..., immutable. The ETag changes if the document or any parameter changes, so it is safe to cache aggressively.
The ETag changes with the parameters. Converting the same PDF to fast and balanced produces different ETags.

What goes into the ETag calculation

The ETag is a hash derived from the binary content of the document plus the response_format. Parameters that do not change the resulting Markdown (for example filename, which is only used to detect format and name the answer) do not enter the hash.

Real use cases

Idempotent network retries. If your client retries an upload because the timeout expired but the conversion did finish on the server side, a second attempt with If-None-Match avoids paying and processing the same document with the same parameters. Ingestion pipelines with reprocessing. If your pipeline reprocesses the same batch of PDFs every night (for example, to regenerate embeddings) and most documents did not change from the previous day, save the ETag per document. It allows you to skip converting everything that didn’t change. Debugging “why the output changed”. If you notice that the Markdown of a document changed between two calls that you thought were identical, compare the ETags: if they are different, some parameter (or the document itself) changed — it is a quick way to discard “weird cache” and confirm that the entry really It’s different.

Example with requests (Python)

Troubleshooting

ETag only saves reconversion on the server; you still pay the network cost of uploading the document again. To avoid that too, use /convert/from-url with output_url or save your own local copy of Markdown indexed by ETag.