"Go" speed up website access--yslow limit optimization

Source: Internet
Author: User

YSlow is a set of Yahoo website scoring system, detailed list of the impact of the page loading speed parameters, here do not say long.

I have been referring to YSlow to do blog optimization, after a long period of study is also a harvest, small Bo's YslowV2 score reached 94 points (even yes!). ), if the use of blog small site scoring standards can be achieved.

Let me summarize some of the ways we can optimize our methods and share them with you.

The following is a new refresh of the load map, the following article used to get:

I think that Web optimization is divided into two main categories, the individual is called soft optimization and hard optimization. Soft optimization mainly includes: Server cache class and browser local cache class, these optimizations are mainly changes in parameter settings. The hard optimization includes: transmission line, cdn,http request number, bandwidth and other basic items.

Our small blog can do the main, but also I want to introduce the main soft optimization class.

One, make fewer HTTP requests (reduce the number of HTTP requests)

Page loading, each file is an HTTP request, including HTML,JS,CSS, images, etc. And each file loading requires DNS query (can be ignored), establish a connection, send the request (can be ignored), wait for reply, download the file, a total of 5 steps, the file is loaded in sequence, the time will be increased, the more files, the longer.

Here is a look at my host small children's Shoes blog loading diagram:

It is a long line, Orange JS, blue html, green CSS, purple img, although more than 1 seconds to respond, but the final load time of 9 seconds.

And the face of such a Web page, we have to do is:

Put CSS all in one file (copy and paste the line)

Put JS all into a file (copy and paste on the line)

Use as few pictures as possible in the theme

If you have to use a picture, the background image is all in a file (this is synthesized in Photoshop, call the background image with Background:url (all.png) no-repeat a few px, to control the background position)

The frames page can be removed all go, each frame page is equal to the new open a page.

After the optimization, the entire page only 1 js,1 css,1 background images and a number of article image page loading speed is at least 2/3 increased.

Second, add Expires headers (added cycle header)

What is called cycle head ah, is actually to give the file a shelf life.

Do not expire directly from the local call, after the expiration of the new will have to change.

This is simple, just add the following code at the end of the. htaccess file at the root of the Web site (only the Linux hosts have. htaccess)

Where Axxxxxx is the time, unit of seconds.

<ifmodule mod_expires.c> expiresactive on ExpiresDefault A3600 expiresbytype image/gif A2592000 ExpiresByType Image/png A2592000 expiresbytype image/jpeg A2592000 expiresbytype text/plain A604800 expiresbytype application/ X-shockwave-flash A2592000 expiresbytype video/x-flv A2592000 expiresbytype application/pdf A2592000 expiresbytype text /html A600 expiresbytype image/x-icon A2592000 expiresbytype application/javascript A604800 expiresbytype text/css A604800 </IfModule>

When this is set, the second access will call the local cache directly, only the HTML is downloaded again, fast,

Third, Configure entity tags (etags) (Configure the Entity tag setting ETag)

Honestly, I don't know what the ETag is, and the explanation on the Internet is that he's the equivalent of a tag to confirm that the elements in the browser cache are consistent with the original server, but they don't say how to set it up. Finally found a how to set up the article, but the author is also not very understand, the author is the Million-GE heroes.

His method is to add this sentence in the. htaccess.

Fileetag None

To be honest, I didn't understand why I had to set it to none, but it worked, and YSlow the score to a would certainly be good enough.

Iv. optimize the order of external calls. (Personal thoughts, may be wrong)

This is the most easily overlooked.

As far as I can see, all the elements are not loaded together at the same time, but it is not a single by one so loaded, it has a few connection concurrent download situation, observe the article head small bo loading diagram, 第1-3个 picture is concurrent. So the order of invocation determines the load order, and the load order determines who and who is in the concurrency.

I have done experiments, if JS file in

Then the JS placed in the body of the footer, the situation will improve a lot, JS follow a large number of images loaded together, shared time, such as the article Head of small Bo loading diagram.

And most importantly, the HTML loading is finished to display the DOM elements, do not have to wait for JS to complete and then display.

Five, server cache

Old topic, WP generally use plug-in cache, I use Wp-cache, it can normally take about 1 seconds to load the HTML in dozens of milliseconds loaded into.

With the picture local cache, two open pages are basically seconds open. (This is the normal loading speed of Beau):

Vi. Other

Others are left with some piecemeal optimizations, and these effects are relatively small.

For example, the theme of all the changes in the content of the PHP statement directly into text, such as the blog name of God Horse.

Also, Css,js compression, a little bit faster.

Local DNS selection (in the NIC properties), the first time access, dns-look-up (DNS query) also accounted for a considerable time, if your DNS ping is higher.

Cookie-free domain settings: The meaning is that each time the connection is established, the client must first send a cookie to the server, and set the Cookie-free can save this time. Personally feel that there is not much time, do not send a cookie, user review information to write their own, experience is not good, not recommended settings.

First write so much, the rest of the thought of a second supplement. Reprint please indicate the source.

I have a groove oh, after the article and then measured again yslow, changed 100 points, the last 100 or the second grade of the primary school thing.

Lao Chai

Original address: HTTP://LAOCHAI.NET/49

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.