当前位置:网站首页>Differences between server-side rendering and client-side rendering (advantages and disadvantages)
Differences between server-side rendering and client-side rendering (advantages and disadvantages)
2022-06-12 12:04:00 【Mustang (Mustang)】
The difference between server-side rendering and client-side rendering
Server-side rendering ?
In the early days of the Internet , The browsers that users use are those that do not have complex logic 、 Simple pages , These pages are on the back end html Spliced , Then return to the front-end complete html file , The browser gets this html The file can be parsed and displayed directly , This is called server-side rendering .
Client rendering ?
As the complexity of front-end pages increases , The front end is more than just an ordinary page display , Maybe it's a component that adds more functionality , More complex , in addition , here ajax The rise of , Make the page begin to worship the development mode of front end and back end separation , That is, the back end does not provide complete html page , But to provide some api So that the front end can obtain json data , Then the front end gets json The data is then processed at the front end html Page splicing , Then show it on the browser , This is called client-side rendering
The most important difference between client-side rendering and server-side rendering is who does it html Complete splicing of documents
The advantages and disadvantages of server-side rendering are ?
advantage :
- The front end takes less time . Because the back end is spliced html, The browser just needs to render directly .
- advantageous to SEO. Because there is a complete html page , So it's easier for reptiles to get information , Better for seo.
- No need to occupy client resources . That is to say, the work of parsing template is completely left to the back end , The client only needs to parse the standard html page , This takes up less resources for the client , Especially the mobile end , It can also save more power .
- Back end generates static files . That is, generate the cache fragment , This can reduce the time wasted in database query , And it's very efficient for pages with little data change .
shortcoming : - It's not conducive to the separation of front and rear ends , Low development efficiency .
Use server-side rendering , There is no division of labor , For projects with high front-end complexity , It is not conducive to the efficient development of the project . in addition , If it's server-side rendering , The front end is usually written as a static html file , Then the back-end is modified to a template , It's very inefficient , And it often needs the front and back ends to complete the modification action together ; Or the front-end directly html Templates , And then hand it over to the back end . in addition , If the back end changes the template , The front end also needs to be adjusted according to the changed template css, This increases the time of front and rear end joint commissioning . - Occupy server-side resources .
That is, server-side completion html Template resolution , If there are more requests , Will cause certain access pressure to the server . And if you use front-end rendering , It's to share the pressure of parsing with the front end , And here it's all over a server .
The advantages and disadvantages of client-side rendering are ?
advantage : - Fore and aft end separation . The front end focuses on the front end UI, The back end focuses on api Development , And the front end has more selectivity , Instead of following the back-end specific template .
- Experience better . such as , We make the website SPA Or part of it SPA, such , Especially the mobile end , Can make the experience closer to the original app.
shortcoming : - The front-end response is slow . If it's client rendering , The front end also needs to splice strings , It takes extra time , Not as fast as server-side rendering .
- It's not good for SEO. At present, such as Baidu 、 Google crawler for SPA They don't recognize , Just recorded a page , therefore SEO Is very poor . Because the server may not save the complete html, But through the front end js Conduct dom The joining together of , So the crawler can't crawl information . Unless search engines seo Can be added to JavaScript Crawling capacity of , That's the guarantee seo.
Whether to use server-side rendering or client-side rendering ?
Regardless of the business scenario, blindly choosing which rendering method to use is playing hooligans . For example, enterprise websites , The main function is presentation without complex interaction , And need good SEO, Then we need to use server-side rendering ; And similar to the background management page , The interaction is relatively strong , Unwanted seo The consideration of , Then you can use client-side rendering .
in addition , The specific rendering method used is not absolute , For example, some websites now use the first screen server-side rendering , That is, the server-side rendering is used for the page that the user first opens , This ensures the rendering speed , Other pages are rendered on the client side , This completes the separation of the front and rear ends .
边栏推荐
- promise的理解已经利用promise实现图片的预加载(顺序加载)
- The first thing with a server
- 关于报文
- 文件夹目录结构自动生成
- ioremap
- DOM+JS+轮播图+无时间
- [QNX hypervisor 2.2 user manual] 4.1 method of building QNX hypervisor system
- 影响店铺权重的三十一条,快来看看中招了吗
- Must do skill -- use ffmpeg command to quickly and accurately cut video
- Chaîne la plus longue sans caractères dupliqués (leetcode 3)
猜你喜欢

promise的理解已经利用promise实现图片的预加载(顺序加载)

Elk construction guide

7-5 复数四则运算

TinyMCE series (I) TinyMCE environment construction

PIP install in the CONDA environment cannot be installed into the specified CONDA environment (the default PIP installation location of the CONDA environment)

UML series articles (31) architecture modeling - deployment diagram

A. Prefix range

6.6 rl:mdp and reward function

Find the median of two ordered arrays (leetcode 4)

Reprint --win10 open the task manager to solve the blue screen problem
随机推荐
ioremap
Promise controls the number of concurrent requests
PDSCH related
机器学习之决策树
Chaîne la plus longue sans caractères dupliqués (leetcode 3)
Design of virtual scrolling list
Who moved my package lock
Relation entre les classes et à l'intérieur des classes de classification vidéo - - Régularisation
关于报文
ARM处理器模式与寄存器
Design of tablewithpage
QT based travel query and simulation system
必杀技--使用FFmpeg命令快速精准剪切视频
Common debugging tools and commands for ROS
邻居子系统之ARP协议数据处理过程
ARM指令集之数据处理类指令
object.defineProperty 基本使用
Neighbor item status update of neighbor subsystem
【Leetcode】416. Split equal sum subset
Thirty one items that affect the weight of the store. Come and see if you've been hit