by FinalBriefing · 4y ago · 0 comments
* SEO capabilities * Faster response for first page load
And for both of those, a CDN is useful, if not essential - you're missing out on a lot of performance boost if you don't.
Other reasons to have SSR include things such as unfurling, where a CDN isn't essential, but still nice to have.
Also, you can achieve this behaviour on CDNs from a full SSR response with just using stale-while-revalidate in the Cache-Control header.
while this is certainly the easiest path, you don't HAVE to put all your ui states on the server. its trivially easy to plugin alpinejs for small ui state stuff that is all client side.
Another huge benefit, the js escape hatch lets you create a bidirectional bridge between your custom js and your user's liveview instance.
It's definitely doable, and I know the PETAL stack (Phoenix Elixir Tailwind Alpine) is super popular, but it's nice (and perhaps less error prone) to have all of your UI logic handled by a single framework. This consolidation of UI code under a single framework was one of the killer features of SPAs initially. Prior to that lots of sites were built with a server side templating framework with jquery sprinkled in for client side UI updates.
Disadvantage: the individual components are not as nicely packaged up with markup/css/logic in a single file and must be hooked up to the global socket explicitly.
Don't get me wrong, it's pretty good and just the fact that you're pushing these stats reflects quite well on my (external) impression of Phoenix: most don't even bother to try and just resort to "hardware is cheap".
It's just that this should be the default. Reminds me of this tweet from @SwiftOnSecurity:
> Once you understand your computer has 16 cores running at 3GHz and yet doesn't boot up in .2 nanoseconds you understand everything they have taken from you.
Clearly this is doing a lot more work than serving static content, but .... dozens per second? Even per-core, that's a shockingly low number.