This is the 26th day of my participation in Gwen Challenge

Following on from the previous front end suggestions for speeding up your website, we will continue to learn how to configure the server side to speed up your website’s responsiveness.

The server

Use the CDN

Cdn-content Delivery Network IS a collection of Web servers distributed in multiple locations to deliver Content to users more efficiently. For example, CDN for network proximity, by specifying a server to deliver content to a user. For example, choose the server with the least number of network hops or the server with the fastest response time. For example, if Beijing and overseas users visit the same website and use CDN to download resources, the actual response server may be different. Static resources, such as HTML, CSS, JavaScript, images, etc., can be configured through THE CDN to speed up the website.

80-90% of a website’s response time is spent downloading all the components of the page: images, style sheets, scripts, Flash, etc. Moreover, it is easy to achieve speed increase through CDN.

You can use your own CDN or your CDN service provider.

Yahoo noted that its site responded more than 20 percent faster after using CDN.

Add Expires or cache-Control to the response header

Advice:

  1. Static resource: setExpires, never expire;
  2. Dynamic resource: UseCache-ControlHelps browsers implement conditional requests.

Browsers use caching to reduce the number and size of HTTP requests, making web pages load faster. Web servers use Expires in the HTTP response header to tell browsers how long a component can be cached.

The diagram below, is our access to baidu encyclopedia entry: Expires, url: baike.baidu.com/item/expire… , the response header of one of the network resource images, circled in the figure:

Expires: Mon, 28 Jun 2021 10:23:28 GMTCopy the code

If Expires is used, the back end needs to change the file name so that the front end can retrieve the updated file from the server. Related policies include adding the version number to the resource file name.

Another related field is ExpiresDefault, which sets an expiration date relative to the current date. As follows:

ExpiresDefault "access plus 10 years"
Copy the code

The optimization effect of using caching is only for non-first-time users, and the actual effect depends on how often they visit your site. Yahoo says it uses caching for 75 to 85 percent of all page resources on its site, which reduces the number of repeated requests for resources on its site.

Other tips for speeding up your website:

  1. Tips for speeding up your website