Zi 字媒體
2017-07-25T20:27:27+00:00
Client-side Render 和 Server-side Render 在實作起來究竟有什麼差別?Debug 時有什麼不一樣,對 SEO 又會有什麼影響呢?
Client-side Render 和 Server-side Render (以下簡稱 CSR、SSR)最主要的差別,就在於有了資料後要在前端渲染還是在後端渲染。在一篇論文《Architectural Styles and the Design of Network-based Software Architectures》(RT Fielding, 2000)中提到:
A distributed hypermedia architect has only three fundamental options:
render the data where it is located and send a fixed-format image to the recipient;
encapsulate the data with a rendering engine and send both to the recipient;
send the raw data to the recipient along with metadata that describes the data type, so that the recipient can choose their own rendering engine.
簡單來說一個分散式多媒體架構不外乎三種架構:
把資料繪製成圖片(或 HTML)傳給前端
把資料和渲染引擎都丟給前端,讓前端照著這個引擎來渲染
把原始資料和描述的後設資料都丟給前端,讓前端自己決定要怎麼渲染
CSR 和 SSR 的差別
這也影響到了後來的 CSR 和 SSR。如果你使用像是 PHP 的語言,通常你會寫出類似這種東西:
寫了
5860316篇文章,獲得
23313次喜歡