mapbox / mapbox-sdk-js

A JavaScript client to Mapbox services, supporting Node, browsers, and React Native
Other
718 stars 186 forks source link

should we always add ?fresh=true to style requests #364

Closed andrewharvey closed 4 years ago

andrewharvey commented 4 years ago

I've encountered instances where getStyle would return an outdated version of the style for a few minutes after updating and publishing changes in Studio. I've seen ?fresh=true sometimes added as an argument to workaround this, but doesn't look to be a documented flag.

Given when working with getStyle you usually want the freshest style should we automatically pass this?

samanpwbb commented 4 years ago

Hey @andrewharvey 👋. We intentionally do not make fresh=true default for two reasons:

  1. Requests that use this param bypass Mapbox's caching, and request times can therefore be quite a bit slower.
  2. Requests that use this param have a significantly lower rate limit than cached requests.

There are a few valid use-cases for fresh=true, for example, to preview a change in your app if you're co-developing a style and an app at the same time, but it should never be used in production / high concurrency environments.

Hope this helps clarify things, and we'll get some documentation up around fresh=true soon.

okdistribute commented 4 years ago

Hi, thanks for that @samanpwbb. I am in need of fresh=true for previewing changes in the app where we're using a style.

Is it possible to pass this directly to the getStyle function today?