Nginx performance tuning key features

1. Expires cache time optimization Function: Set a reasonable expires cache time on the server. Types suitable for caching: Static files: html, pictures, js, css, and xml are all cache objects. Advantages: It can make users do not have to download again every time they visit, improve the speed of user visits and improve user experience, and save server bandwidth resources. Disadvantages: The cached page or data is updated, and the user sees the old content. Solution: 1. Reduce the cache time, for example: 1 day (at the cost of sacrificing performance, incomplete, unless the update frequency is greater than 1 day, which is not the optimal choice) 2. Rename the cached objects, pictures and attachments will generally not be affected User modification, if modified, is actually changing the file name and re-transmitting. Js, css website upgrade, generally can be renamed. Check method: Firefox browser can use firebug and Yslow two plug-ins to check or curl command. curl -I http://…….. Cache date check of corporate website: 51cto: 1 week, Sina: 15 days, Jingdong: 25 years, Taobao: 10 years, objects that generally do not want to be cached: 1. Advertisement image 2 Website traffic statistics files 3. Frequently updated files 2. nginx Gzip compression module optimization needs and objects that do not need to be compressed: 1. Plain text files larger than 1K html, js, css, xml, shtml, etc. 2. Do not compress pictures, videos, etc., because not only will it not be effective, but the compression will consume CPU and MEM resources. 3. More beautiful display of error pages http://oldboy.blog.51cto.com/2561410/716294 (list of common HTTP status codes in production environment) Key configuration: error_page 500 502 503 504 /50x.html Notes: 1. You must add fastcgi_intercept_erros on; if this option is not set, even if 404.html is created and error_page is configured, it has no effect. Add the location in the http, server, location section. 2. Do not designate the homepage as a 404 error page for the purpose of saving trouble or increasing the weight of the homepage, and do not use other methods to jump to the homepage. 3. The custom 404 page must be larger than 512 bytes, otherwise IE’s default 404 page may appear. For example, suppose 404.HTML is customized and the size is only 11 bytes (the content is 404 error). If the 404 page content is too small, IE will cause an error, and Firefox is OK.

1. Expires cache time optimization Function: Set a reasonable expires cache time on the server. Types suitable for caching: Static files: html, pictures, js, css, and xml are all cache objects. Advantages: It can make users do not have to download again every time they visit, improve the speed of user visits and improve user experience, and save server bandwidth resources. Disadvantages: The cached page or data is updated, and the user sees the old content. Solution: 1. Reduce the cache time, for example: 1 day (at the cost of sacrificing performance, incomplete, unless the update frequency is greater than 1 day, which is not the optimal choice) 2. Rename the cached objects, pictures and attachments will generally not be affected User modification, if modified, is actually changing the file name and re-transmitting. Js, css website upgrade, generally can be renamed. Check method: Firefox browser can use firebug and Yslow two plug-ins to check or curl command. curl -I http://…….. Cache date check of corporate website: 51cto: 1 week, Sina: 15 days, Jingdong: 25 years, Taobao: 10 years, objects that generally do not want to be cached: 1. Advertisement image 2 Website traffic statistics files 3. Frequently updated files 2. nginx Gzip compression module optimization needs and objects that do not need to be compressed: 1. Plain text files larger than 1K html, js, css, xml, shtml, etc. 2. Do not compress pictures, videos, etc., because not only will it not be effective, but the compression will consume CPU and MEM resources. 3. More beautiful display of error pages http://oldboy.blog.51cto.com/2561410/716294 (list of common HTTP status codes in production environment) Key configuration: error_page 500 502 503 504 /50x.html Notes: 1. You must add fastcgi_intercept_erros on; if this option is not set, even if 404.html is created and error_page is configured, it has no effect. Add the location in the http, server, location section. 2. Do not designate the homepage as a 404 error page for the purpose of saving trouble or increasing the weight of the homepage, and do not use other methods to jump to the homepage. 3. The custom 404 page must be larger than 512 bytes, otherwise IE’s default 404 page may appear. For example, suppose 404.HTML is customized and the size is only 11 bytes (the content is 404 error). If there is too little content on the 404 page in Internet Explorer, an error will occur, and Firefox is OK.

Leave a Comment

Your email address will not be published.