Sync and caching
Sync the registry
Keeping a local copy for a wallet or explorer: bootstrap once, then poll for changes and removals.
-
Bootstrap
Download /v2/assets/all.json once (use gzip). Record the largest
updated_atassince, and the largestaudit_idfrom GET /v2/audit?order=desc&limit=1 ascursor. -
Check whether anything changed
Send a cheap conditional request first, e.g.
GET /v2/assets?page_size=1withIf-Modified-Sinceset to theLast-Modifiedyou saw last time. 304 means no asset changed, removals included: skip this round. Otherwise note the newLast-Modified, run the steps below, and store it only after they complete. -
Poll for changes
Page newest-first with
GET /v2/assets?sort=updated_at_desc&updated_after=<since − 1 s>&page_size=500until a page is empty or its last item is older thansince. Upsert each asset byasset_id.- The one-second overlap catches ties:
updated_afteris strictly after, and many assets can share oneupdated_at(many share the icon-import time). Expect duplicates. - Store the new
sinceonly after a complete pass, so an interrupted pass is retried.
- The one-second overlap catches ties:
-
Poll for removals
Deregistered assets disappear from every listing (404 on lookups), so
updated_afternever reports them. Read them from the log:GET /v2/audit?operation=deregister&since_audit_id=<cursor>and the same withoperation=legacy_deregister. Delete eachaction.asset_idlocally and advancecursortonext_since_audit_id.
A removed asset can be registered again later; your change poll will pick it up as a new asset.
Caching
| Response | Header | Advice |
|---|---|---|
| Icon by hash | public, max-age=31536000, immutable + ETag | Cache forever |
| Current icon redirect | no-cache | Revalidate |
Asset reads (/v2/assets…, legacy /, /index.json, /:asset_id, /icons.json) | no-cache + Last-Modified | Revalidate: send the last Last-Modified in If-Modified-Since; 304 (no body) means nothing changed. Or sync incrementally |
| Other JSON (audit log, …) | none | Cache briefly yourself |
Last-Modified is registry-wide: it is the time of the last change to any asset, including removals and icons, so every listing, page, lookup and the icon map change together. A 304 on any of them therefore means no asset changed at all.
Updated about 4 hours ago