Caching and CORS
On this page
Every 200 carries an ETag. Send it back and an unchanged manual is a 304 with no body. Public manuals may be cached for a minute; anything a token unlocked is never cached. All three addresses allow any origin for GET.
ETag and 304
The ETag is a fingerprint of the answer. Send it back as If-None-Match, and if nothing changed the answer is 304 Not Modified with the same headers and no body. A 304 still counts as a request; see how calls are counted.
# First call: keep the ETag it gives you
curl -sS -D headers.txt https://stylehub.cloud/api/v1/manuals/acme/tokens.json -o tokens.json
ETAG=$(grep -i '^etag:' headers.txt | cut -d' ' -f2 | tr -d '\r')
# Later: 304 and an empty body if nothing changed
curl -sS -o tokens.json -w '%{http_code}\n' \
-H "If-None-Match: $ETAG" \
https://stylehub.cloud/api/v1/manuals/acme/tokens.jsonThe PDF has an ETag too, made from everything the document was drawn from, so an unchanged manual is a 304 there as well and no document is drawn or sent. A document out of the server's recent cache is not counted as a render; see the PDF's own allowance.
Cache-Control
A 200 or 304 also says Vary: Authorization, so a cache that does keep a public answer never serves it to a request that carried a different key.
CORS
Access-Control-Allow-Origin: *on every answer, errors included. A page on any site can fetch a public manual directly.- Methods:
GETandOPTIONS. A preflight answers 204 and may be cached for a day. - Request headers allowed:
AuthorizationandIf-None-Match. - Headers exposed to the page:
ETag, the threeX-RateLimitheaders andRetry-After.
const res = await fetch("https://stylehub.cloud/api/v1/manuals/acme.json");
console.log(res.headers.get("x-ratelimit-remaining"), "requests left this minute");
const manual = await res.json();A token never belongs in a browser page
Search engines
Every answer from the three addresses says X-Robots-Tag: noindex. The API is data, and the page is the thing search engines should find. See Search engines and the head of a page for how a manual itself is indexed.
Something the API does that this page does not say? Write to hello@stylehub.cloud with the request and the answer you got.