Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server : (web ui) Enable gzip compression for local storage #10945

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

exxocism
Copy link

@exxocism exxocism commented Dec 22, 2024

Description

  • The size of localStorage typically ranges from 2 MB to 10 MB, depending on the browser.
    • This capacity can be quickly exhausted under certain conditions (MDN, GeeksForGeeks)
  • This pull request introduces gzip compression for localStorage by intercepting the storage methods, effectively increasing storage capacity by up to 4 to 5 times.
  • The feature is migratable from uncompressed to compressed storage but not vice versa.
  • It can be disabled using the useCompression switch.
  • Can easily be extended to brotli or other compression method

Major changes

  • Adds pako library for gzip compression: 03a44d8
  • gzip interception to the web ui: b3c5268
  • Pack gz file: 94e7d24

Test env

  • Check the values in the chrome console
  • Check if it migrates smoothly from uncompressed to compressed

TODO

  • Pre/Post merge step: none

@ngxson
Copy link
Collaborator

ngxson commented Dec 22, 2024

IMO this feature is not really needed, because compressing localStorage can make it tricky to debug, while only provide at maximum 5x storage, not scalable.

The more scalable would be to migrate to IndexedDB, which provide at minimum 50MB of storage according some sources on internet (although usually there is no hard limit). There are also many libraries that provide easier-to-use interface.

I would appreciate if you can write an interface for IndexedDB. The compressed localStorage is not a valid solution atm, we can only keep it as a demo if you want to continue.

@exxocism
Copy link
Author

Thanks for the opinion. I agree that migrating to IndexedDB is a good idea, and I’ll explore ways to implement it with minimal changes.
Perhaps we can turn off the useCompression switch and allow some users to make good use of it in the meantime.

@ngxson
Copy link
Collaborator

ngxson commented Dec 22, 2024

We can keep this PR as a demo, but I don't think we can merge it to master, given that IndexedDB is preferred way to go.

@ngxson ngxson added the demo Demonstrate some concept or idea, not intended to be merged label Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
demo Demonstrate some concept or idea, not intended to be merged examples server
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants