当前位置:网站首页>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 .
边栏推荐
猜你喜欢

JS to load and display Excel files

Inter class and intra class relations in video classification -- regularization

左右案例+小圆点的轮播图+无时间

Design of virtual scrolling list

Create servlet project

mysql复习

QT添加QObject类(想使用信号和槽)遇到的问题汇总,亲测解决有效error: undefined reference to `vtable for xxxxxx(你的类名)‘

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

Chaîne la plus longue sans caractères dupliqués (leetcode 3)

Design of secure chat tool based on C #
随机推荐
Lambda and filter, List 和 numpy array的索引,以及各种距离指标distance-metrics,拼接数组以及axis=0 and axis=1的区分
Getting started with NVIDIA Jetson nano Developer Kit
TinyMCE realizes automatic uploading of pasted pictures
ARP protocol data processing process of neighbor subsystem
QML学习 第一天
object.defineProperty 基本使用
A. Prefix range
Why is there no traffic after the launch of new products? How should new products be released?
Cookies and sessions
传统的DOM渲染方式?
Basic concepts of machine learning
Automatic generation of folder directory structure
判断网络文件是否存在,获取网络文件大小,创建时间、修改时间
ARM指令集之Load/Store指令寻址方式(二)
树的前序,中序,后序遍历
Kubernetes cluster setup
Relation entre les classes et à l'intérieur des classes de classification vidéo - - Régularisation
ioremap
Beyondcompare 4 uses PJ
【深度学习基础】反向传播法(1)