当前位置:网站首页>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 .
边栏推荐
- ioremap
- Conversion between ROS map picture pixels and map coordinate system coordinates
- Beyondcompare 4 uses PJ
- 单页面开发与多页面开发的优缺点
- LeetCode_ String_ Simple_ 344. reverse string
- First understand the onion model, analyze the implementation process of middleware, and analyze the source code of KOA Middleware
- Open source project - (erp+ Hotel + e-commerce) background management system
- 作物模型的区域模拟实现过程初探
- Kubernetes cluster setup
- Elk construction guide
猜你喜欢
随机推荐
Cookies and sessions
Spark common encapsulation classes
Pytoch notes
Inter class and intra class relations in video classification -- regularization
Data processing instruction addressing method of arm instruction set
QML first day
ioremap
Channel Shuffle类
ARM指令集之数据处理类指令
左右案例+小圆点的轮播图+无时间
QT based travel query and simulation system
The second regular match is inconsistent with the first one, and the match in the regular loop is invalid
LeetCode 497. 非重叠矩形中的随机点(前缀和+二分)
影响店铺权重的三十一条,快来看看中招了吗
【QNX Hypervisor 2.2 用户手册】4 构建QNX Hypervisor系统
PIP install in the CONDA environment cannot be installed into the specified CONDA environment (the default PIP installation location of the CONDA environment)
ioremap
Chapter VI data type (V)
文件夹目录结构自动生成
LeetCode_ Binary search_ Medium_ 162. looking for peaks








