1 Basic Concepts

What is routing? For example, for GET or POST requests, the server will maintain a regular configuration table. When the request matches a specific URL path, it will be distributed to different controllers. After processing, the HTML or data will be returned to the front end, thus completing an IO interaction. This is the solution that most web sites use today, and it’s called back-end routing, or multi-page applications.

2 Back-end route

The benefits of back-end routing are:

  • Once rendered by the server, it can be returned directly to the browser.
  • SEO friendly.

SEO (Search Engine Optimization) : Chinese translation for Search Engine Optimization. The use of search engine rules to improve a site’s natural ranking within the relevant search engines. Its purpose is: to provide ecological self-marketing solutions for websites, so that they can occupy a leading position in the industry and gain brand revenue; SEO includes two aspects: off-site SEO and in-site SEO; In order to get more free traffic from the search engine, from the site structure, content construction scheme, user interaction, page and other aspects of reasonable planning, but also make the search engine displayed in the website information is more attractive to users.

The disadvantage is that:

  • Because templates are written and maintained on the back end, front-end developers need to learn back-end languages such as Java and install a back-end service development environment.
  • Pages, data, and logic are mixed and difficult to maintain.

3 Front-end Route

Front-end routing is the core of single page rich application (SPA). SPA is to add a layer of back-end routing on the basis of front and back end separation. Routing rules are maintained by the front end. It can be implemented in two ways:

  • Using the HASH of the URL, the anchor (#), JavaScript uses the hashChange event to listen for changes to the URL. This method is implemented by polling in IE7 and earlier versions.
  • HTML5’s Histroy mode allows urls to be separated by “/” without causing a page to jump (the server directs all requests to the same HTML page).

This gives the SPA a single HTML page to which all the content of the site points.

The advantages of front-end routing are:

  • Page persistence.
  • Front and rear ends separated.