-2

I am getting my head around to understand serviceWorkers, web workers and indexedDB. I understand their usage in a web application. I have 2 questions.

  1. I am developing jquery widgets like color picker, date picker, token field, etc... Is it a good idea to use indexedDB to cache data retrieved from server for libraries like tokenfield, combobox that has data fetch from the server?
  2. I am planning to use web workers for these libraries but am not sure whether this is feasible. Have any other uicomponent providers like Bootstrap tried using web workers? and what could be the issues I will be facing?
vbrin27
  • 723
  • 1
  • 6
  • 25

1 Answers1

0

Usually, workers are used for a big calculating task (for example for parse file in the background without blocking main thread and hence UI), working with a network (into service workers it is possible to catch network requests and return something without going to server - it is useful for PWA). I think that using workers for storing data from UI components like color picker throw worker to indexedDB is redundant. Usually, this kind of data is not very important and sensitive, hence the best choice to store it - local storage.

Genrikh
  • 9
  • 2
  • I will not be using storage for color picker but only for components which might involve ajax fetch from the server like tokenfield. But the local storage allows us to store only strings and so is it advisable to stringify the response JSON and store it in localStorage? @Genrikh – vbrin27 Sep 09 '19 at 11:25
  • I don't understand this line - "I think that using workers for storing data from UI components like color picker throw worker to indexedDB is redundant". Can you explain it? @Genrikh – vbrin27 Sep 09 '19 at 11:26
  • My opinion is that there are no reasons for using indexedDB with a worker to cache some data. – Genrikh Sep 09 '19 at 11:48
  • And about local storage - probably you get JSON from a server and you can cache it in local storage as a string. – Genrikh Sep 09 '19 at 11:49
  • I need not use workers with indexedDB. If I use indexedDB without workers, is it an unnecessary overhead instead of using local storage? I might need to store nearly 6000/more records in JSON format. @Genrikh – vbrin27 Sep 09 '19 at 13:43