Step 10 teaches you how to optimize WordPress speed to reduce pressure on servers and visitors

Source: Internet
Author: User
Tags free cdn w3 total cache wordpress database

1. Static cookie Creation

It takes about 80% to 90% of the time, and the visitor will spend a lot of time waiting for your Wordpress to Load Static content. This means that most of the time users browse your website, they are waiting to load, such as: images, CSS, JS scripts, Flash, etc. Therefore, you can optimize the content so that WordPress can load a cookie domain more quickly. It eliminates some of the precious time for load. Of course, this may not seem much, but only when other delays are added can we really reduce the time loss.

I don't know what other source code websites should do, but WordPress is very simple as long as you modify the wp-config.php!

Add:

Define ("wp_content_url", "http: // static. ***. com ");

Define ("cookie_domain", "www. ***. com ");

Then, use the code "bloginfo (template_directory") "to add the static content you want to implement!

2. Set static content Cache

For static content caching, I will not introduce it much. You also need this step to use the relevant cache plug-in, that is, to modify the. htaccess file.

The Code is as follows:

<Ifmodule mod_expires.c>
Expiresactive on
# Perhaps better to whitelist expires rules? Perhaps.
Expiresdefault "access plus 1 month"
# Cache. appcache needs re-Requests
# In FF 3.6 (THX Remy ~ Introducing HTML5)
Expiresbytype text/cache-manifest "access plus 0 seconds"
# Your document html
Expiresbytype text/html "access plus 0 seconds"
# Data
Expiresbytype text/XML "access plus 0 seconds"
Expiresbytype application/XML "access plus 0 seconds"
Expiresbytype application/JSON "access plus 0 seconds"
# RSS Feed
Expiresbytype application/RSS + XML "access plus 1 hour"
# Favicon (cannot be renamed)
Expiresbytype image/X-icon "access plus 1 week"
# Media: images, video, audio
Expiresbytype image/GIF "access plus 1 month"
Expiresbytype image/PNG "access plus 1 month"
Expiresbytype image/jpg "access plus 1 month"
Expiresbytype image/JPEG "access plus 1 month"
Expiresbytype video/Ogg "access plus 1 month"
Expiresbytype audio/Ogg "access plus 1 month"
Expiresbytype video/MP4 "access plus 1 month"
Expiresbytype video/webm "access plus 1 month"
# HTC files (css3pie)
Expiresbytype text/X-component "access plus 1 month"
# Webfonts
Expiresbytype Font/TrueType "access plus 1 month"
Expiresbytype Font/OpenType "access plus 1 month"
Expiresbytype application/X-font-woff "access plus 1 month"
Expiresbytype image/SVG + XML "access plus 1 month"
Expiresbytype application/vnd. MS-fontobject "access plus 1 month"
# CSS and JavaScript
Expiresbytype text/CSS "access plus 1 year"
Expiresbytype application/JavaScript "access plus 1 year"
Expiresbytype text/JavaScript "access plus 1 year"
<Ifmodule mod_headers.c>
Header append cache-control "public"
</Ifmodule>
</Ifmodule>

3. Optimize the database

There is a way to reduce the pressure on the server. How can we optimize the WordPress database? Naturally, code is used and code is used. Hey, you may not be able to edit it for several hours! The free WordPress plug-in makes this problem easy. I personally recommend Yoast optimize dB and WP dB manager. Keep in mind that most cache plug-ins also help a lot, so you will find that most of them are taking care of the workload of your existing cache software.

4. cache media as much as possible

You can easily create a cache using a plug-in. Essentially, these new features are converted to static pages. All of these methods facilitate loading and save the lag of your browser front-end. So, listen to my suggestions for plug-ins.

My favorite cache tools are WP super cache, hyper cache, and W3 total cache. Using these to generate HTML files can save more time.

5. Use CDN

CDN acceleration is currently very popular, so naturally there is a certain reason, because CDN can be accelerated. Yes, CDN is generally charged, but CDN is also available for free.

We recommend some practical free CDN:

Free CDN: webluker, cloudflare

6. Compress JS and CSS files

You may have heard of the library transfer of JS and CSS files, but you have never heard of compression. Haha, this method is very whimsical, but someone has done it and developed a practical tool for compression. Of course, the compression of the machine is not satisfactory. You can also manually compress it.

JS compression tools recommended: Closure compiler, Minify Javascript. CSS compression tools recommended: Minify CSS, CSS Compressor

7. compressing Images

Image loading is also time-consuming. If you try BMP or PSD as an image, the speed must be the same as that of snail scanning. I do not recommend high-quality PNG files. We recommend that you try JPG compression! Otherwise, the image will be distorted.

You can use the WP smush. It plug-in to compress images!

8. gzip Compression

Gzip compression is good to a certain extent! In addition, Gzip compression can not only accelerate, but also shield the advertisement (the gospel of free space). gzip compression code will be handed over to you! Modify the. htaccess File

<Ifmodule mod_deflate.c>
# Force deflate for mangled Headers
# Developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/
<Ifmodule mod_setenvif.c>
<Ifmodule mod_headers.c>
Setenvifnocase ^ (accept-encodxng | X-cept-encoding | X {15} | ~ {15} |-{15}) $ ^ (gzip | deflate) S *,? S *) + | [x ~ -] {} $ HAVE_Accept-Encoding
Requestheader append accept-encoding "gzip, deflate" Env = HAVE_Accept-Encoding
</Ifmodule>
</Ifmodule>
# HTML, txt, CSS, JavaScript, JSON, XML, HTC:
<Ifmodule filter_module>
Filterdeclare Compress
Filterprovider compress deflate resp = Content-Type $ text/html
Filterprovider compress deflate resp = Content-Type $ text/CSS
Filterprovider compress deflate resp = Content-Type $ text/plain
Filterprovider compress deflate resp = Content-Type $ text/XML
Filterprovider compress deflate resp = Content-Type $ text/X-component
Filterprovider compress deflate resp = Content-Type $ application/JavaScript
Filterprovider compress deflate resp = Content-Type $ application/JSON
Filterprovider compress deflate resp = Content-Type $ application/XML
Filterprovider compress deflate resp = Content-Type $ application/XHTML + XML
Filterprovider compress deflate resp = Content-Type $ application/RSS + XML
Filterprovider compress deflate resp = Content-Type $ application/atom + XML
Filterprovider compress deflate resp = Content-Type $ application/vnd. MS-fontobject
Filterprovider compress deflate resp = Content-Type $ image/SVG + XML
Filterprovider compress deflate resp = Content-Type $ application/X-font-TTF
Filterprovider compress deflate resp = Content-Type $ Font/OpenType
Filterchain Compress
Filterprotocol compress deflate change = yes; byteranges = No
</Ifmodule>
<Ifmodule! Mod_filter.c>
# Legacy versions of Apache
Addoutputfilterbytype deflate text/HTML text/plain text/CSS application/JSON
Addoutputfilterbytype deflate application/JavaScript
Addoutputfilterbytype deflate text/XML application/XML text/X-component
Addoutputfilterbytype deflate application/XHTML + XML application/RSS + XML application/atom + XML
Addoutputfilterbytype deflate image/SVG + XML application/vnd. MS-fontobject application/X-font-TTF font/OpenType
</Ifmodule>
</Ifmodule>

9. Disable etags

I may not understand etags either, but you can only use it to speed up, So you care about him and etags. Do you mean no?

+ This line in the. htaccess file!

File etag none

10. server environment

Using the lamp or lnmp environment can better support WordPress with a low risk factor and high security. It is estimated that your server or VPs will not be restarted for several years, so what should I do if I forget to restart my Linux Password on the Internet! This is free of charge. It's really a lie down and shot!

Summary:

Most of these methods are applicable only in lamp or lnmp environments. Therefore, to use WordPress, you must use it in Linux. In win environments, you may encounter column problems!

This article from: Rice Grain grain tutorial dining room group | http://www.wg369.com/archives/1989.html

Step 10 teaches you how to optimize WordPress speed to reduce pressure on servers and visitors

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.