In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
In this issue, the editor will bring you about the ways to help you improve your website access speed and shorten the page loading time. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
Internet users do not like to spend too much time waiting for the web page to open, the longer the wait, the user may directly close the web page, which will lose a lot of traffic! Secondly, the ranking of keywords is also related to the opening speed of the web page, which mainly reflects the search engine on the user experience, the user experience is good, ranking is better than other sites. Therefore, I think it is necessary for us to improve the opening speed of the web page, this does not need too much cost investment, just need to pay more attention to some tips! Here are 20 ways to improve your website access speed and shorten page loading time.
1. Reduce the number of page HTTP requests
A more direct understanding is to reduce the number of calls to other pages and files.
a. When we use css format control, we often use background to load a lot of graphics files, and each background image generates at least one HTTP request. Generally, we use background to load the background image in order to make the page lively. To improve this situation, we can use a useful background-position attribute of css to load the background image. We synthesize multiple images that need to be loaded frequently into a single picture. When you need to load, you can reduce the HTTP request loaded by this part of the image to 1 by loading in the following form.
Background:url (....) No-repeat x-offset y-offset
b. Using Image maps, this method is also more commonly used, but is limited to the same area.
C.Inline images, this method is rare, but for very small and simple images is very practical, the relevant syntax standard reference: tools.ietf.org/html/rfc2397.
2. Use CDN (Content Delivery Network) network acceleration
Now there are many companies that do CDN acceleration business in China, to put it simply, it is to spread your pictures and videos to where the CDN network can reach, so that users can download these files nearby when they visit, so as to achieve the purpose of increasing the speed of the network, so as to reduce the load on your own website at the same time.
3. Add file expiration or cache headers
For pictures and Js script files frequently accessed by the same user, you can set their buffer time in Apache or Nginx, such as 24-hour expiration time, so that when users visit the page again, the same group of pictures or JS will not be downloaded repeatedly, thus reducing HTTP requests, user access speed has been significantly improved, while the server load will also be reduced. The following is an example of cache control in nginx configuration:
Location ~. *\. (gif | jpg | jpeg | png | bmp | swf) ${expires 30dscape # set 30-day expiration} location ~. *\. (js | css)? ${expires 1hscape # set 1 hour expiration}
4. Enable gzip compression on the server
As we all know, the content that needs to be transmitted is compressed and then transmitted to the client and then decompressed, so that the amount of data transmitted on the network will be greatly reduced. Usually, the Apache and Nginx on the server can directly enable this setting, or you can set the transfer file header directly from the point of view of code, increase the setting of gzip, or set it directly from the load balancer device. It is important to note, however, that this setting slightly increases the burden on the server.
5. Css format definition is placed in the header of the file.
This setting is more advantageous for the situation where the user side is a slow network or the web page content is relatively large, and the formatting information can be maintained while the web page is gradually presented, without affecting the aesthetic feeling of the web page.
6. Put the Javascript script at the end of the file
Many Javascript scripts are inefficient, or some third-party domain name scripts are accidentally unable to load. If these scripts are placed at the front of the page, the content loading speed of our own website may slow down or even fail to load normally, so these scripts are generally placed at the end of the web page file. Be sure to load the scripts in front of them using the so-called "post-load" method. Load after the loading of the main page to prevent it from affecting the loading speed of the main page.
7. Avoid using CSS scripts (CSS Expressions)
Sometimes in order to dynamically change the parameters of css, css expression may be used to implement it, but the loss outweighs the gain and will significantly increase the burden on the client browser, so it is not recommended to do so. If you need to change it, you can use Javascript script to implement it.
8. Css and javascript are called externally.
If the css, js content is relatively large, try not to write to the same page, but by the external load is more appropriate, because the browser itself will cache css, js files.
9. Compress Javascript and CSS code
In general, there are a large number of spaces, line breaks and comments in js and css files, which are convenient for reading. If they can be compressed, they will be very beneficial to network transmission. There are also many tools in this area, generally you can retain the development version, use the tool to generate a production version, compared with two files, the general compression ratio can reach more than 50%, the reduction of the amount of data is still considerable.
My blog has just been revised, all kinds of code has not been optimized and compressed, the current yslow rating can only reach D, and so there is time for partial optimization, reaching C level should not be a big problem.
10. Avoid using 301 and 302 steering
Develop good development and maintenance habits and avoid repeated calls to scripts as far as possible
12. Configure ETags
13. Ajax is called by cache
The use of this can be referred to the Discuz forum code, which uses cache calls for a large number of Ajax calls, generally using additional characteristic parameters, and pay attention to the
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.