nusmodifications / nusmods

🏫 Official course planning platform for National University of Singapore.
https://nusmods.com
MIT License
588 stars 319 forks source link

RFC: Server-side rendering for static pages #1018

Open ZhangYiJiang opened 6 years ago

ZhangYiJiang commented 6 years ago

I believe it should be possible to make NUSMods SSR without too much pain. The main benefit of this is that the static like FAQ and semi-static pages like the module/venue pages should load much faster, and SEO on those pages will also be much better. The additional server load will be mitigated by adding a caching layer in front of the renderer.

The key steps are to making SSR work are (reference: https://medium.freecodecamp.org/demystifying-reacts-server-side-render-de335d408fe4)

Open questions

ZhangYiJiang commented 6 years ago

Progress on this issue can be tracked on the we-ssr-now branch. It's pretty interesting all of the technical issues I've faced so far

Also, on an architecture level I believe implementing SSR will cause the app to be more monolithic. This is because the data layer can now be shared between server and client. Imagine if we have a GraphQL store - the SSR server will then just query it locally to fetch the data. This is pretty neat if you think about it.

li-kai commented 6 years ago

Aside from the DOM and async stuff, the rest of the issues can be solved with webpack on the server side.

Long ago I actually had an entire SSR code base that I learned over at Carousell, it was intended to be a learning thing so it was private. Just made it public: react-prod-learn. Ultimately I didn't go with SSR because of the problems you raised and we don't actually see much benefit aside from performance (which comes with a pretty heavy cost).

ZhangYiJiang commented 6 years ago

The previous comment is outdated. I've fixed/hacked around most of these issues, and have found some new ones