After calling Update Styles (POST) or Delete Styles (DELETE) using the Mapbox Styles API a subsequent call to List Styles (GET /styles/v1/{username}) returns stale style data. e.g. after calling DELETE and then calling CREATE the GET call will still return the deleted style!
Waiting about 5 minutes will usually return the latest, correct style data. Clearly some caching happening on the Mapbox end but deletes or updates should be reflected immediately.
Anybody confirm or provide a workaround?
This is indeed because of how our default caching behavior works for these API endpoints.
The style list endpoint specifically has a default Cache-Control value of 5 minutes (i.e. Cache-Control: max-age=300). You can confirm by looking at the headers of the API response:

It's possible to get around this default behavior by including the query parameter fresh=true in your request. Making your full request look like:
GET /styles/v1/{username}?access_token={scopes:styles.list}&fresh=true
Including this query parameter will cause the API to serve you a response with Cache-Control: no-cache instead, and you will see the most up-to-date style information associated with the username:

⚠️ disclaimer: I currently work at Mapbox ⚠️
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With