1

I have a page where the user inputs a list of (potentially) thousands of strings, which then leads to a page that uses this list. I tried to just use a query parameter to pass the strings to the latter page, but according to another StackOverflow post that would exceed several browsers' URL length limits, although it worked just fine on Chrome, Firefox and Safari when I tested it. Are there any alternatives to passing massive a query parameter?

Note: One alternative would be to switch to a single-page app but I'd like to avoid that much complexity if it's possible.

Community
  • 1
  • 1
quadrupleslap
  • 460
  • 1
  • 6
  • 18

2 Answers2

2

URL has a length limit which is not standardized. It depends on which browser and which version of the browser you're using. You're probably safe with about 2000 characters of total URL length.

If you want to avoid that, instead of issuing a GET request to a different page, you should create a POST request which has no limits.

The other alternative is using SPA where you're not actually sending anything over the HTTP and send the data in-memory instead.

Ivan Ferić
  • 4,725
  • 11
  • 37
  • 47
0

Save the data in localstorage or some client db like indexedDB, then retrieve it on the other page.

Angels
  • 230
  • 1
  • 8
  • Just beware with this, because if your users have multiple tabs open on your site, they all share the same local storage so you might find one tab starts picking up data from another tab. For example if you have an online shop and you are editing two orders in two different tabs, suddenly one tab might update the order that was opened in the other tab. You can work around it by including a "session ID" in your local storage and passing that in the URL, so that each tab knows which set of data to load from local storage. – Malvineous Feb 03 '23 at 07:32