Answer the question
In order to leave comments, you need to log in
Websockets instead of regular connections?
This question has been asked a thousand times and the answer to it is this:
Sockets are needed for one, ordinary requests for another. You don't have to mix.
I agree with those who think so, but let's look at a specific example:
We have a SPA site. After the page is loaded, the application makes 5 Ajax requests to the API to render 5 modules on the page. In the usual case, these are just 5 requests that return the necessary information and the application draws the desired block. Another request leaves when the user clicks on some tab. The information for this tab is also loaded via a request.
The above scenario is found all over the place. Why not establish a socket connection instead of 6 Ajax requests and get all this information through it? After all, we thereby at least save time on establishing a connection for each request, right? Why is this approach not practiced?
Answer the question
In order to leave comments, you need to log in
Caching? No, have not heard.
Of course, you can use anything on your project, even send smoke signals with a blanket. Nobody will forbid you.
Maybe one day they will tell you: what if our conversion rate is not very good, and Google rates it at 29 points out of a hundred? And then you change.
Or maybe no one will tell you anything, and it will work until it closes.
Well, ajax is a little easier to develop, debug, and maintain.
1) Sockets are a more expensive connection in terms of resources, because it takes up a slot and does not die, it is beneficial where it is needed. There is no need for a spa.
2) Writing code (and then maintaining it) both on the front and on the back is easier (read cheaper) in the classic style than wrapping everything in a socket. Businesses don't like spending extra money. This also applies to paragraph 1.
3) Stalker_RED writes that there may be nuances with caching, I can’t immediately say whether this is so, IMHO this will not be a problem if you only drag the markup with the socket, and take the statics using Orthodox http. In the case of socket statics, of course, you will grab this trouble to the fullest. It confuses me more how the search bot will see the page, but here you won’t know until you build it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question