launchdarkly / js-client-sdk

LaunchDarkly Client-side SDK for Browser JavaScript
Other
113 stars 66 forks source link

Better localStorage space management #310

Open romulof opened 1 week ago

romulof commented 1 week ago

Is your feature request related to a problem? Please describe.

LD SDK shares localStorage space with our app, and there is no constrain on how much data LD SDK can use, leading to unexpected localStorage quota issues.

Describe the solution you'd like

Describe alternatives you've considered

I had to write a procedure for my app init to cleanup old LD cache entries, because I was running out of quota, or simply turn off localStorage cache, slowing down my application.

Additional context

N/A

kinyoklion commented 1 week ago

Hello @romulof,

Thank you for the recommendation. I agree that the SDK shouldn't be unconstrained as it is now.

Our general strategy for this across the SDKs is having a cached context control. By default it does 5 contexts and can be adjusted. It doesn't handle things on the kB level, but the size of the cache for any given context cannot be known ahead of time, so potentially you may have a quota that allows no caching.

We are working on a replacement for this SDK: https://github.com/launchdarkly/js-core/tree/main/packages/sdk/browser

The feature: https://launchdarkly.github.io/js-core/packages/sdk/browser/docs/interfaces/LDOptions.html#maxCachedContexts

If your workaround works in the medium-term, then we should be able to have the new SDK released to resolve the issue.

Generally speaking caching will work different.

Thank you, Ryan