Article From:https://segmentfault.com/q/1010000012138882

A new project recently is an integral shopping mall, so I want to realize data interface for front end calls through RESTful.

First of all, the backstage is also using RESTful as the interface of the management side (implemented by SpringBoot). This project does not include any pages, only interfaces.
Then use Nginx or Apache to do the front-end page, pure static, request RESTful interface through Ajax to achieve data interaction.

Another set of RESTful interfaces is used for mobile terminals (APP and public numbers), and does not include any pages.
The front end also requests interfaces through pure static pages.
In this case, will the page presentation performance of the front end (public number) be discounted (for example, to show the details of the product, first to request HTML, and then back to the data through the Ajax request interface)?
Management background is not so high in performance, so it can manage information well.

I wonder if this scheme is feasible? How would it be better to be optimized?

Answer 0:

It shouldn’t, one of our last projects was this way, at that time the PC website, pure static HTML plus Ajax plus rest, no problem, HTNL loading speed was very fast, the only problem was that if Ajax access was too slow to load the page, we were at the same time at the same time.The GIF animation in the middle of the request does not seem to be a problem. Slow is certain.

Answer 1:

For your question, if the front and rear ends are separated, the first thing to consider is
1.Performance problems of back end rendering and front-end rendering
2.Security issues in the front end
If you only look at the performance issue, the performance may not be obvious, no matter backend rendering or back-end rendering. Because if the rear end rendering is to increase the pressure of the server, the front end rendering is the matter of the browser.
So each has its own advantages and disadvantages.

Answer 2:

The request for static files is very fast.

But Ajax requests more, rendering the page will appear carton. This is the best way to control the number of requests. 3~5 is fine.

You can tune Json format, Js processing logic, and so on. Now the browser engine is also very fast, reducing the pressure of the server is better.

Answer 3:

If you worry about too many Ajax requests, you can consider giving up GraphQL on RESTful.

Leave a Reply

Your email address will not be published. Required fields are marked *