Pages

Wednesday, October 7, 2015

Single Page Application Cloud Storage.

Single Page Application Cloud Storage.
We already wrote about how our cloud storage can be used as the platform for static sites (1 and 2). Today we tell about how you can store on the basis of postmodern Sites, which are based on popular and relevant today approach Single Page Application (SPA).

SPA's Approach

SPA abbreviation stands for «single page application» («one-page application). In a narrow sense, it is used to denote a single-site, directly executed on the client side in the browser. In a broader sense, SPA (sometimes also used the abbreviation SPI - «single page interface») means the whole approach to web development, which today is becoming more widespread. What is the meaning of this approach, and why it is becoming more popular

We start from a somewhat remote. Today, the most common type of sites are, of course, dynamic sites in which the generation of pages is carried out on the server side. With all the obvious convenience for developers (each request creates a page from scratch), such sites often pose a real headache for customers.
This is not a complete list of inconveniences with which they have to face

Even despite the fact that some frameworks allow to return in response to a form filled with data, the entered customer the last time, the need to reload the page for the validation does work with a site uncomfortable.

Generation of pages on the server side is associated with serious workloads.
Often described problems are solved this way the page is still generated on the server side, but on the client side JavaScript-run small scripts that can be used, for example, perform validation form before it is sent to the server.

The decision at first sight is quite good, but it has disadvantages

If before the frontend and backend functions are clearly separated (backend is responsible for generating the view and logic, and front end of the display), it is now duplicated on the front end logic that can hardly be called a good architectural practice.

The code that is responsible for the generation of view, have to constantly duplicate and because of this there are problems, kopipasta discrepancy markup broken selectors complexity maintainable code, etc.
Of course, to live with all of this possible. But the approach SPA in many cases much more efficient.

From the standpoint of this approach site is not understood as a set of pages as a set of conditions and the same HTML-pages. If you change the status occurs asynchronously uploading new content without reloading the page itself.

SPA is not a site in the classic sense, and an application that runs on the client side in the browser. Therefore, from the point of view of the user problems with the speed of work almost never, even at a slow or unstable Internet connection (for example, when viewing the site from a mobile device). High speed operation is ensured even and because the server to the client is no longer comes counting and the data (mainly in JSON format), and their size is small.

Recently, a lot of interesting technology solutions and services, greatly simplifying the creation and use of the SPA. Let us consider some of them in more detail.

BAAS (Backend as a Service)

Technologies that render the interface on the client and server communicate only by sending requests without reloading the page, there is already a long time. For example, API XMLHttpRequest appeared more in 2000. But the use of these technologies have been difficult it was necessary to rewrite the backend that implements the functions of authorization requests and data access.

Today everything has become much easier thanks to the emergence of numerous BaaS-services. Abbreviation BaaS means Backend as a Service. BaaS-services provide Web application developers ready server infrastructure (located usually in the cloud). Thanks to them, you can save time (and often more money) to write server-side code and focus on the improvement of the application and development of its functionality. With BaaS can connect to an application or any backend site with any set of functions - simply add to the page corresponding to the library.

As an example, the service MongoLab, allowing you to connect to the Web applications and sites cloud database MongoDB.

Another interesting example - FireBase. This service is a cloud-based database and API for realtime-applications. Use it, in particular, to organize the exchange of data between the client and the server in real-time just connect to the page JavaScript-library and set up the event to change the data. Based FireBase easily implemented, for example, chat or feed of user activity.