One day, the manager makes a statistical temporary page about the sales performance of the company on the TV, to the customers to visit the day to watch. First stage: Scenario: temporary function, small data volume, simple SQL, short development time. Countermeasures: All things are placed in a controller inside, JS and CSS and other data written in the view layer, data real-time query. The company's rapid development, this temporary page since put on the television has never come down (I have a feeling of the pit (⊙﹏⊙) b), and the boss required a lot of new data added, the page has been redesigned. Second Stage scenario: the data volume increases, the SQL becomes more and more complex, at the peak of the system load, the data real-time query has caused the great pressure to the database. Countermeasure: Optimize SQL, add appropriate index, page increase data cache function. Six months later, this temporary function is still alive (⊙﹏⊙) b, the company's various departments want to show their own data on the above. The third stage scenario: Leaders demand increased data, data is more complex, query SQL is very slow, resulting in very slow page opening. Countermeasures: Because of the real-time data before the day of the requirements are not high, so the data before the day using timed scripts, every morning statistics good, deposited in the statistics, the day of real-time data query timing query. From the view layer to separate JS, CSS and other files, compressed page pictures, JS, CSS and so on. A year later ... The fourth stage scenario: A surge in demand, more data to show, more complex data, a very slow page opening, and sometimes 30 seconds is not necessarily open. Countermeasures: Reduce the host controller, separate complex data, use lazy loading, local refresh, page increase fragment cache. Page load, load the whole page frame and simple data, so as to ensure the opening speed of the page, the complex data from the main controller, to reduce the load time of the host controller, local complex data, such as the entire page loaded through Ajax from the background.
Optimization of a temporary page