3 ms·
In most applications, replacing HTTP with WebSockets is a big mistake. HTTP is cachable, can be proxied, inspected via curl and examined in Chrome's devtools.
by loevborg 8y ago
In most applications, replacing HTTP with WebSockets is a big mistake.
HTTP is cachable, can be proxied, inspected via curl and examined in Chrome's devtools. More importantly, typical app communication with the server has request-response shape. If you're communicating over a WebSockets connection, that doesn't change the natural shape of your queries. So you have to correlate requests and responses and multiplex over the connection - essentially reimplementing HTTP, but poorly!
If you have the choice, request-response communication is preferrable because it's always going to be simpler than bidirectional communication. If server push is an important part of your user experience, implement it as an addition to your HTTP routes and as a completely separate pathway (and consider using SSE instead of WebSockets).