2 ms·
this is great - i implemented something similar in a recent project, where we have some state being persisted "at the edge" (in cloudflare workers' key-value st
by kmf 7y ago
this is great - i implemented something similar in a recent project, where we have some state being persisted "at the edge" (in cloudflare workers' key-value store product, workers kv) and cached in-browser using local storage. we wrote a bit about it here[1], though our approach[2] has changed a bit even since this post went out.
instead of directly interfacing with window.localStorage, we opted to use lscache[3], which allows us to expire keys: `lscache.set(key, value, 5)` (expires in 5 minutes)
[1]: https://blog.cloudflare.com/jamstack-at-the-edge-how-we-built-built-with-workers-on-workers/ https://blog.cloudflare.com/jamstack-at-the-edge-how-we-buil...
[2]: https://github.com/cloudflare/workers.cloudflare.com/blob/master/src/components/bookmark_state.js https://github.com/cloudflare/workers.cloudflare.com/blob/ma...
[3]: https://github.com/pamelafox/lscache https://github.com/pamelafox/lscache