Public reads and caching
Available
Reading public lot and fruit records without a credential, and how long a copy may be cached.
The /v1/public/… routes need no credential and answer only what the public pages show. An id that is unknown, hidden or not public answers the same 404, so a 404 says nothing about whether a record exists.
A shared cache between you and CropPath (CropPath's content delivery network) may keep the answers of public reads:
- 200:
Cache-Control: public, max-age=0, s-maxage=60, stale-while-revalidate=300. A shared cache may answer with a copy up to 60 seconds old, and for 300 seconds more while it fetches a new one. Browsers always check again (max-age=0). - 404:
public, max-age=0, s-maxage=60, never served stale, so a record made public shows within a minute. - 400, 429 and server errors:
no-store. - A fruit's recording (its URL names its SHA-256) is
public, max-age=31536000, immutable. A lot's EPCIS download has anETag(the SHA-256 of its bytes): sendIf-None-Matchto get a 304.
So a change of status (a recall, a hold, a seal) can take up to 360 seconds to reach a cached copy. When you need the status now, for example before you accept goods, read past the cache: add a query parameter of your own with a new random value (the web pages use fresh), which the API ignores. A company can also subscribe to webhooks for its own lots: lot.sealed, lot.recalled, lot.withdrawn and lot.trust_tier_changed (sent only when the displayed trust tier changes). Webhooks never report another company's lots, so everyone else reads past the cache.
/public-scan/<id> belongs to the fruit page of the web site: it counts a consumer's scan, is never cached and refuses requests from other sites (403). Integrations must not call it; read GET /v1/public/fruits/{publicId}, which counts nothing.