Home > Web Front-end > Front-end Q&A > What is the use of node middle layer?

What is the use of node middle layer?

WBOY
Release: 2022-04-22 11:24:41
Original
3001 people have browsed it

The role of the node middle layer is to separate functions and reduce the burden on the board; when there are too many requests, the request for processing the page rendering can be assigned to another service, and only data-related requests will be processed, so that the front end can focus more on the view. layer, allowing more data logic to be processed in the node layer, avoiding the duplication of data verification on the front end and verification on the back end at the same time.

What is the use of node middle layer?

The operating environment of this tutorial: windows10 system, nodejs version 12.19.0, Dell G3 computer.

What is the use of node middle layer

The advantages of using Node as the Web middle layer:

1. Separation of functions to reduce the burden on the board

2. Page data verification and logic code can be reused across systems and terminals. There is no need to rewrite the verification due to the access of new systems and terminals;

3. Only do it in the middleware One-time data verification avoids the duplication of data verification on the front end and verification on the back end, effectively ensuring the validity of the data while reducing the overall workload of the team;

4. Processing Data logic liberates the front-end from having to do both page rendering and writing complex logic, allowing page developers to focus on page rendering. This not only makes the division of labor clearer and makes project collaboration more efficient, but more importantly, responds quickly to the page so that the page loads. Faster, better user experience, avoiding the unfriendly experience of the browser displaying a blank page for a long time;

The node middle layer can do the following work:

Proxy: In the development environment, we can use proxies to solve the most common cross-domain problems; in the online environment, we can use proxies to forward requests to multiple servers.

Cache: Caching is actually a requirement closer to the front end. User actions trigger data updates, and the node middle layer can directly handle part of the caching requirement.

Current limiting: The node middle layer can limit the current in response to interfaces or routes.

Log: Compared with other server-side languages, the logging in the node middle layer can more conveniently and quickly locate problems (whether on the browser side or the server side).

Monitoring: Good at high-concurrency request processing, monitoring is also a suitable option.

Authentication: There is an intermediate layer for authentication, which is also an implementation of a single responsibility.

Routing: The front-end needs to master the permissions and logic of page routing.

Server-side rendering: Node middle-layer solutions are more flexible, such as SSR, template direct export, using some JS libraries for pre-rendering, etc.

The role of the node middle layer:

The front-end is also mvc. After NodeJS, the front-end can focus more on the view layer and let more data logic be processed in the Node layer.

When you find that the volume of all requests is too much to cope with, you can consider such a separation, assign the processing of page rendering requests to another service, block it in front, and only be responsible for data-related requests. nodejs is good at handling io-intensive tasks and is very suitable for services that handle page rendering

Recommended learning: "nodejs video tutorial"

The above is the detailed content of What is the use of node middle layer?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template