DopplerHQ / cli

The official CLI for interacting with your Doppler secrets and configuration.
https://docs.doppler.com
Apache License 2.0
214 stars 43 forks source link

[FEATURE] idea: stale-while-revalidate for secrets #423

Open osdiab opened 11 months ago

osdiab commented 11 months ago

Is your feature request related to a problem? Please describe. Checking for new secrets every time we run commands just makes running every command slower; it has to do a round trip to Doppler. But secrets only change occasionally in our project, so it would be more valuable to have our commands run speedily than to always have the freshest secrets.

Describe the solution you'd like Similarly to "stale-while-revalidate" when caching content on the web, give the Doppler CLI an option to just use the secrets from whatever it retrieved last time (so long as it's not too egregiously stale, maybe make it configurable the same way that SWR is), and in the background refresh the secrets so that at least the next time you run the command, if something changed it would be up-to-date.

So the command would run near instantly, but you run the risk of running it with stale values once.

Might be good to additionally have some explicit "refresh" command alongside this when needed.

Describe alternatives you've considered Turning the internet off and using the fallback? lol or just tolerating all our CLI commands stalling for a second before we do anything. But that makes Doppler less fun.

Additional context https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#stale-while-revalidate