5 ms·
> Performance is higher with the server because the HTML is already generated and ready to be displayed when the page is loaded. If you can reasonably cache th
by BackBlast 4y ago
> Performance is higher with the server because the HTML is already generated and ready to be displayed when the page is loaded.
If you can reasonably cache the response, SSR wins on first page load, no question. On the first page dynamic render "it depends", can be SPA or SSR. 2nd page render a well built SPA just wins.
"it depends....." Server CPU cores are slower than consumer cores of similar eras. They run in energy efficient bands because of data center power concerns. They are long lived and therefore are often old. They are often segmented and on shared infrastructure. And if the server is experiencing load, seldom an issue on the client's system, you have that to deal with also. Your latency for generating said page can easily be multi-second. As I've experienced on many a dynamic site.
Using the client's system as a rendering system can reduce your overall cloud compute requirements allowing you to scale more easily and cheaply. The user's system can be made more responsive by not shipping any additional full page markup for a navigation and minimizing latency by avoiding network calls where reasonable.
On dynamic pages, do you compress on the fly? This can increase latency for the response. If not, page weight suffers compared to static compressed assets such as a JS ball that can be highly compressed well ahead of time at brotli -11. I never brotli -11 in flight compression. Brotli -0 and gzip -1.
This is for well built systems. Crap SPAs will be crap, just as crap SSR will similarly be crap. I think crap SPAs smell worse to most - so there's that.
> Compatibility is higher with server-side rendering because, again, the HTML is generated on the server, so it is not dependent on the end browser.
If you use features the end client doesn't support, regardless of where you generate the markup, then it won't work. Both servers and clients can be very feature aware. caniuse is your friend. This is not a rule you can generalize.
> Complexity is lower because the server does most of the work of generating the HTML so can often be implemented with a simpler and smaller codebase.
Meh. Debatable. What's hard is mixing the two. Where is your state and how do you manage it?
If you're primarily a backend engineer the backend will feel more natural. If you're primarily a front end engineer the SPA will feel more natural.
- roncesvalles 4y agoYes it's totally moronic. In fact we should be moving more server-side work to client machines, with WASM and such.
- Sohcahtoa82 4y ago> On dynamic pages, do you compress on the fly? If there's any secret info being transmitted (ie, session tokens) and you're using TLS, you shouldn't be using compression. https://en.wikipedia.org/wiki/CRIME_(security_exploit) https://en.wikipedia.org/wiki/CRIME_(security_exploit) https://en.wikipedia.org/wiki/BREACH https://en.wikipedia.org/wiki/BREACH
- pas 4y agoMobile cores are usually power/thermal constrained. Still parsing HTML or running an ungodly amount of JS that then spits out that HTML on the device is not that big of a difference, both kill the battery charge fast :)
- BackBlast 4y agoAs I said, servers cores are also power and thermal constrained. A16 is like 50% faster than high frequency latest and greatest Sapphire Rapids single core. 50%.
- pas 4y agoBusinesses are not server-side compute limited. Ask any business basically. They would gladly trade more of their own CPU power & heat for more time on the site/service from their users.
- BackBlast 4y agoI didn't say they were compute limited, did I? Still, Pouring unlimited funds on more servers so they can sit <10% idle for best client performance is a great way to light money on fire. Faster -> more responsive. The client's cores are faster, even on mobile. If that's such a great trade, SPAs are potentially better than dynamic SSR.