0

I have a 40-50MB JSON object that I need to persist across to a different page. This only needs to happen once (one transition) but I'm still way over HTML5 LocalStorage limits, what other options do I have?

susdu
  • 852
  • 9
  • 22
  • Might work in indexedDb. Limits are browser specific though. See https://stackoverflow.com/questions/5692820/maximum-item-size-in-indexeddb – charlietfl Oct 21 '18 at 12:04
  • I feel that setting up an SQL-like DB looks like an overkill for what is just a big temporary variable – susdu Oct 21 '18 at 12:09
  • 1
    Might be if you were within localStorage limits but that's not the case. Alternatively is use server or cloud storage to deliver only what is needed on demand – charlietfl Oct 21 '18 at 12:11
  • 40-50 mb JSON is a lot. I think you need to refactor your server code to send only the needful data. – rohitwtbs Oct 21 '18 at 13:18
  • Do you really need all 50MB in browser at once? Can you page it into the browser's memory? (Items 0-1000 on page 1, 1001-2000 on page 2, and so on.) You should use File API I hope. – localroot Oct 21 '18 at 13:28

2 Answers2

0

Unfortunately, that is too much data to store for most browsers. Even combining sessionStorage and localStorage both will not get us even close.

There are a few options you can try though:

  • You can store the data on your own server. This will depend on what web server/environment you are using.
  • You can use someone else's server to store the data. For example, you could use Google Drive's API. This does mean that your user needs a google account. You could also pay for a service like Amazon S3 to store it.
  • You could create a 'container' page, which loads and displays the pages, but keeps the session going. How exactly this works depends again on your environment.
Bronzdragon
  • 345
  • 3
  • 13
0

40-50m is too huge for a browser, the worse part is if mobile is involved, what you can do is split the data into chunks, keep some in sessionStorage, localStorage and the remaining on your server, so that the part on the server will be fast enough to load, You will have to join them once all is loaded and done. I wouldn't recommend this method though.

Big Zak
  • 1,040
  • 12
  • 17