Home  >  Article  >  Backend Development  >  Why don’t e-commerce websites bind data directly but use js to define data?

Why don’t e-commerce websites bind data directly but use js to define data?

WBOY
WBOYOriginal
2016-08-18 09:16:361053browse

JD.com, wait a minute, why not bind the page data directly, but use js var data=[]... to define and then bind the data to the page.

  • Separation of front and back ends?

  • Performance optimization?

Why don’t e-commerce websites bind data directly but use js to define data?

Reply content:

JD.com, wait a minute, why not bind the page data directly, but use js var data=[]... to define and then bind the data to the page.

  • Separation of front and back ends?

  • Performance optimization?

Why don’t e-commerce websites bind data directly but use js to define data?

For large websites like JD.com and Taobao, data reading is very complicated and cannot simply be read from an interface. The main approximate data is divided into the following categories

  • Read data directly
    Read the latest data directly from the server. Only a portion of the data does this because there is too much pressure on the service. This step may be server-side rendering.

  • Cached data
    If reading the latest data from the server fails, or the real-time performance is not strong and there is no need to read the latest data, use cached data. to reduce pressure on the database.

  • Disaster recovery data
    If the machine suddenly fails, or the program crashes, and both direct reading of data and caching of data fail, disaster recovery data will be used. Disaster recovery data is generally saved to the client in localStorage or userData after successfully reading the first two types of data. Even if there is a server-side failure, the page can still be displayed normally. It just might not be the latest data.

    So like Taobao and JD.com, even if something goes wrong. Nor does it affect user browsing (which may affect operations).

So it’s difficult to analyze why it is used in this way just by looking at the title picture.

Put rendering on the client to reduce server pressure

Statement:
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