What is SSR ?
伺服器端渲染 (SSR) 是一種網頁渲染技術,其工作原理是在將網頁發送至客戶端瀏覽器之前先在伺服器端進行渲染。
這意味著網頁的 HTML、CSS 和 JavaScript 代碼是在伺服器端生成的,而不是在瀏覽器中。
SSR (Server-Side Rendering) stands for Server-Side Rendering.
It is a technique for rendering web pages on the server before sending them to the client's browser.
This means that the HTML, CSS, and JavaScript code for the page is generated on the server, rather than in the browser.
Pros
- 提升 SEO 效果: SSR 可以改善搜尋引擎優化 (SEO),讓搜尋引擎更容易理解和索引您的網站內容。這是因為搜尋引擎可以直接訪問已渲染的 HTML 內容,其中包含重要的資訊,例如頁面標題、元描述和標題。
- 縮短初始頁面載入時間: 對於具有大量 JavaScript 的複雜網站,SSR 可以縮短初始頁面載入時間。這是因為瀏覽器在開始渲染頁面之前不需要下載和解析 JavaScript 代碼。
- 減輕客戶端負擔: SSR 可以減輕客戶端的負擔,特別是對於處理能力有限的行動裝置。這是因為渲染頁面的繁重工作是在伺服器端完成的,而不是在客戶端。
- Enhanced SEO: SSR can improve search engine optimization (SEO) by making it easier for search engines to understand and index your website's content. This is because search engines can directly access the rendered HTML content, which includes important information like page titles, meta descriptions, and headings.
- Reduced Initial Page Load Times: For complex websites with a lot of JavaScript, SSR can shorten initial page load times. This is because the browser doesn't need to download and parse the JavaScript code before it starts rendering the page.
- Lighter Client Load: SSR can reduce the load on the client, especially for mobile devices with limited processing power. This is because the heavy lifting of rendering the page is done on the server, rather than on the client.
Cons
- 增加伺服器負擔: SSR 會增加伺服器負擔,特別是對於流量大的網站。這是因為伺服器必須生成每個頁面檢視,這可能會消耗大量資源。
- 潛在的延遲: SSR 會引入一些延遲,特別是對於遠離伺服器的使用者。這是因為瀏覽器必須等到伺服器生成頁面後才能開始顯示它。
- Increased Server Load: SSR can increase server load, especially for high-traffic websites. This is because the server has to generate every page view, which can be resource-intensive.
- Potential Latency: SSR can introduce some latency, especially for users located far away from the server. This is because the browser has to wait for the server to generate the page before it can start displaying it.
When to use SSR ?
- 具有大量 SEO 相關內容的網站: SSR 可以幫助您在搜尋引擎結果頁面 (SERP) 中獲得更高的排名。