WordPress Site Speed Optimization

Source: Internet
Author: User
Keywords WordPress

Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall

Site optimization is a lot of benefits, in large part, mainly has the following points:

1. Page loading speed increased exponentially

Depending on the site's original state and degree of optimization, the effect of ascension is different. Generally can promote 3~5 times.

2. Reduce site traffic

The amount of space that is limited by the flow of traffic is equivalent to saving money.

3. Reduce server load

Traffic savings, but also reduce the load on the server, for CPU utilization limit, the number of concurrent unlimited space, it means that the maximum number of concurrent increases.

Since there are so many advantages, it is of course to optimize the site, the following specific how to optimize the site:

1. Diagnostic analysis

Before optimizing the site, use the Site Online analysis tool for analysis.

There are a lot of web sites that can be analyzed online, but the most recommended is Gtmetrix (http://gtmetrix.com),

This site provides a full range of inspection and optimization suggestions and current ratings, as well as a very comprehensive test report pdf download function.

In addition to Gtmetrix, Baidu also provides a website speed diagnostic tool, the premise is to install Baidu statistics (http://tongji.baidu.com) before use.

The proposal is best to combine the two analytical tools for the site analysis and inspection, the site of the general situation has an understanding, to understand the problems to be solved.

2. Page static

What is the page static is not more introduced, search for a lot of comprehensive introduction.

WP static tool is the use of Cos-html-cache, specific installation and usage see: Install WP after a few must install Plug-ins.

3. Compress JavaScript, CSS

The compression here is not the use of compression algorithm for the source file compression code, but to remove the file in the blank line comment, such as some useless characters, popular say, is the file pressure.

The tools for compressing JavaScript can be jsmin, using the command line to enter commands Jsmin.exe newfile.js

Originalfile.js to be in the same directory as jsmin.

can also use webmaster tools to provide online compression tools: http://tool.chinaz.com/Tools/JsFormat.aspx

But for some larger JS files or using jsmin compression is better.

CSS words on the webmaster tools provided by the CSS Online compression tool can be: http://tool.chinaz.com/Tools/CssFormat.aspx

4. Merge JavaScript, CSS

WP in the installation of some themes or plug-ins, the head of the application of JS and CSS will be more and more.

When loading a page, each application is an HTTP access, then reduce the number of JS reference, of course, speed up the load.

So you can combine multiple JS into a reference file, and then remove the JS references that are merged.

This step of optimizing the operation is cumbersome and risky, involves modifying the code file, and some JS also invokes other resource files causing the resource call to become problematic after the merge.

So do not recommend WP beginners to do this step, unless the modification is more confident.

5. Turn on gzip compression

Compression here refers to the compression algorithm used to encode files. All the static resources, such as text, pictures, audio, video and so on are compressible, but the compression ratio is different.

The page itself is a text, but the format is HTML, JS, CSS is also text, but the format is different.

By compressing the algorithm, the volume of the text file can be reduced greatly, thus the speed of loading the load is multiplied.

For a site, the currently more common compression method is to enable gzip compression. It sends the page requested by the browser, as well as the static resources referenced in the page, to the client in the form of a compressed package.

Then unpack and assemble on the client. The specific implementation does not care, we just have gzip enabled.

First check to see if the site is enabled for gzip, and you can use the Gzip checking tool provided by Webmaster Tools: http://tool.chinaz.com/Gzips/

If it's already open, then you don't have to open it individually, otherwise you can add two lines to the. htaccess file:

Php_flag zlib.output_compression on Php_value zlib.output_compression_level 5

But just add these two lines is useless, it is only to open the compression module, if the gzip detection site again, the display is still not open.

Because you have not yet specified which types of static resources to compress. Then go ahead and add a few lines to the. htaccess:

<ifmodule mod_rewrite.c> rewriteengine on Rewritebase/rewritecond%{request_filename}-F RewriteRule ^ (. *) (js| css|html|htm) $/gzip.php?file=$1$2&type=$2 [L] </IfModule>

The above specifies that a file called gzip.php file is processed for js,css,html,htm in several suffix name formats, so a further gzip.php is created and placed in the same directory as the. htaccess:

<?php $file =$_get[' file ']; Switch ($_get[' type ']) {case ' CSS ': header ("Content-type:text/css"); Cript "); Break; Case ' HTML ': Header ("content-type:text/html"); Break; Include ($file);?>

Another gzip detection, can be tested in Baidu's testing tools, if all is normal, then have not seen Gzip opened this item.

And in the Webmaster Tools gzip detection, will also show gzip open state.

6. Setting up client-side caching

Static resources on the page are stored in the client's temporary folder once they are referenced.

If the server has set a static resource expiration period, the client will take the static file directly from the temporary folder instead of requesting it before it expires, as long as it accesses the page again.

So after you set up the client cache, once you have visited the page once, the speed of accessing the page again during the expiration period will be greatly improved.

The Set method is also simpler, just add a few lines to the. htaccess:

# Expire Images Header expiresactive on ExpiresDefault A0 expiresbytype image/gif A2592000 expiresbytype image/png A259200 0 expiresbytype image/jpg A2592000 expiresbytype jpeg A2592000 expiresbytype image/ico A2592000 expiresbytype text/ CSS A2592000 expiresbytype text/javascript A2592000

2592000 represents one months meaning, 2592000 = 60*60*24*30

7. Merging domain names

The so-called merge domain name, refers to if there is a reference to other domain name site under the resources, the resources moved to their own site, and modify the resource reference address.

This allows access requests to be performed only under a small number of domain name sites, reducing DNS addressing time.

A popular analogy is that taking things from a warehouse is quicker than taking things from different warehouses.

From the optimization point of view, is to refer to other sites of text, pictures moved to their own site, from their own site reference.

8. Move JS Position

In a page request, JavaScript is loaded before it can load the following content, and CSS can be loaded in parallel.

So the best drop JS references are placed in the end of the page, that is, before.

Here the main site optimization operation is completed, I believe that the completion of this series of optimization, WP site access speed has been greatly improved.

Other

In addition, you can use a very good optimization plug-in autoptimize, it can automatically merge, compress all the JS in the page, and move the reference back. is a high-performance fool-type optimization plug-in, the use of autoptimize, the 2,4,8 step can be skipped, both easy and avoid the modification of the risk of errors and good results.

But Autoptimize's merging of JS is based on PHP format, so it's also a client-side cache of Autoptimize generated. php.

In. htaccess conditions the following code

<ifmodule mod_headers.c> <filesmatch ". (PHP) $ "> Header set last-modified" Oct, Modified unlimited GMT "</FilesMatch> </IfModule>

Last-modified can be specified at any time, but must precede the current time.

Of course, can continue to do a lot of things to improve the speed of the site, such as the use of concise templates, reduce the number of home pages, reduce the page JS code.

Whether it is a beautiful page layout, or site optimization, the ultimate goal is to enhance the user experience.

But please believe in a timeless, universal truth----Simple is beautiful!

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.