Say, is such a moment. The challenge is to develop a web application for the corporate network. Not all customers have fast internet connection. I would like to have a local database - reference books, from where the data would be loaded into the application. What should I do - put Php + mysql on each client for example? Or there are some more elegant solutions. How good is this solution in terms of performance? The network has old hardware and software should work on it. Reference books themselves will rarely be updated. And how to update them - something like the replication of the main base of directories?
- If you have a web application, then where does php on the client. it will not work without a web server with a browser. And in modern browsers there are several types of storage, including SQL-storage. Working with them takes place directly in the browser using javascript - Mike
- there was meant to put a local php interpreter and a local mysql and ajax subd requests, respectively, sent to localhost when referring to directories. Can browsers have access to local files via JS - as far as I know there is no such possibility? - Artem Tikhonovich
- oneWhy do you need access to local files if browsers have embedded SQL servers (usually sqlite). And most directories are actually key-value (the value may be a json object). And for such things, the usual localStorage will do. - Mike
- one@ Artem Tikhonovich synchronization moments - you can see this by the logic of the application. The meaning is as follows: if table A is empty, we tighten table A. And then - the client must somehow find out what it takes to reset the data in table A if the data in table A has changed. How it depends on the task, on the logic. - Goncharov Alexander
- onedepending on what they are used for. If an ID is used to get an object and some info from it, then we are looking for an object in localStorage (it is still more convenient than SQL for such simple tasks), if there is no object, we request the server and write to the repository. If you need a complete list that would show what kind of menu / drop-down list, then we load the whole from the server and, for example, remember the version number of the directory. And when working with the server, we check this number periodically to update it on time - Mike
1 answer
I will answer for the task - if the main interest is to minimize traffic: a backend is much more useful (PHP or Java, C #) - to make a json server. Plus, the server can distribute static nginx-th, which the client immediately caches and adjusts the time when you need to reset the cache. Of course, the web application will then have a thick client that can be implemented on a js framework, such as angular.
The main thing in this case is to properly organize caching on the client so that once downloaded content does not reload: the benefit today is a lot of money for this. For example - the same directories, loaded, put in localStorage, and then take them only from localStorage. This corresponds to the lazy loading pattern, but there may be problems with the question of when to reset the cache: to do this, you need to send a signal to the client, for example, via a permanent websocket connection to the server.
And the local sql as a duplicate of the main database - would not advise, you can spend some time with it because database synchronization is always one of the most complex operations. Although there is something on this topic