SPA: use of websites only. Why not?

I am redesigning a web application that was previously passed to the server side into a single page application and started reading about web folders. The web application will use sockets to have new entries and / or messages sent to the client. I was wondering why most of the pages that use sockets do not handle all of their connections through a socket. In most cases, in addition to the web schedule, there is a RESTful backend. Would it be a bad idea to have a client request for new resources over a socket? If so, why, besides this, can a RESTful api be easier to use with other devices?

I can imagine that using web interfaces would probably not be the best idea if the network connection is poor, as on mobile devices, but this should probably work well with a reasonable network connection.

I found this sibling question, however this is from 2011 and seems a bit dated: websocket api to replace rest api?

+7
websocket single-page-application
source share
2 answers

Returning to this question a few years later, I would like to point out several aspects to illustrate that all your communication through web sockets has its drawbacks:

  • no general compression support. You can easily configure your web server to compress http requests, and browsers are known to be happy to accept compressed responses for many years, but for web sockets this is still not so simple (even if the situation has improved)
  • Client platforms are often built on commonly accepted standards, such as leisure. The further you move away from the expectations of frameworks, the fewer add-ons or features will be available.
  • Browser caching is not so simple. This has come a long way to date, encompassing the realm of offline availability and PWA.
0
source share

No, that would not be a bad idea. In fact, I work in an application that uses a WebSocket connection for everything that data interaction is, the web server processes only resource requests, views in different languages, sizes, etc.

The problem may be the lack of frameworks / tools based on a persistent connection. Over the years, most frameworks, front and back, have been designed and built around a request / response model. A bias approach may not be so easy to take.

+4
source share

All Articles