4 ms·
I feel like using localStorage to cache stuff that could be handled by http caching is probably a mistake. I'm in the process of caching a bunch of our applicat
by SMrF 15y ago
I feel like using localStorage to cache stuff that could be handled by http caching is probably a mistake. I'm in the process of caching a bunch of our application in localStorage because a quirk in our client-side architecture means I need to know if something is cached before making an asynch request for content, (which you can't do with the standard http cache). That means I'm reinventing a cache invalidation scheme -- which we all know is hard, right? Plus the space allocated for localStorage is pretty small, so I have to have a way to prioritize the cache and bump out old stuff to make way for new. It's all rather convoluted.
IMHO, edge cases aside, most people shouldn't do this.
- shantanubala 15y agoCaching assets in localStorage definitely isn't a "best practice," and seems like something that should only be done when necessary. One of the best uses for localStorage though, is caching client-side templates. If you're building an app that's got a ton of different models and templates for each one, it makes your application a lot more efficient to lazy-load them as needed and cache them in localStorage for later use with versioning and cache invalidation.