Wix Backend , Session Storage,Page Code? [Design Advice]

Hey Guys, Wix Team,

I have a file consisting of details of all the countries, states, calling code and currencies in json format. I am using it in lot of dropdowns in my website. So where is the best place to store this json file to maximize the site load speed?

  1. Backend file : Load the Json file every time when the user visit the page

  2. Backend + Session storage : load one time each day and store the file in local storage and then access the data everytime from local storage till next day

  3. Page code : Use the json object in every page where I have the dropdowns

  4. Page code + session storage : Use the json object in every page where I have the dropdowns and store the file in local storage the first time in a day and then access the data everytime from local storage till next day.
    My plan is to use 2. is it a good design choice for optimizing the page speed?

Is there any other suggestions other than these? (There might be some situations where I need to add new countries or new infos in future. That is why I am planning to save the file in local storage each day and rewrite it on the next day in point 2 and 4)

Thanks!!

Hi Nithin,

If data consistency is important in your situation you should also take into consideration a scenario where a user did not refresh his site for a few days and left his machine on, or in any other scenario where the data in local storage is inconsistent with the real data on your site.

As long as the JSON object is not too big using either method to store the JSON object should not affect the load speed in any meaningful way.
A good practice would be to store the data in the backend (either as a JSON object or in a collection) and selectively query it as needed, either by connecting it to a dataset to populate the dropdown boxes, or by grabbing the entire JSON object from the backend.
This will both reduce unnecessary overhead and remove the need to do consistency checks, plus, storing it in a collection will provide an easy to manage platform for future updates.

Hi Ido,
Thanks for your answer i will use the backend method. But just for clarifying things… Is it possible to store an array of array in collections? For example i have a array of countries and each country has an array of states in it… So is it possible to store these in a collection and then use query to populate the drop down options?
Thanks.

Hi Nithin,

Yes.
You can for example add each country as a new line, then add a ‘states’ field with an array object of states.
To populate a dropdown you will have to query and parse the data yourself.