Optimize WordPress in another 4 steps

wordpress

I just moved out from Globat to a new place, Jumpline. It is a good time to clean the house, and throw out all trashes.

Enable WP-Cache + GZIP

Although the official WP-Cache suggests to disable GZIP support, there are some hacks(1, 2) to enable it. That is quite neat.

After this optimization, the total size of front page is 247.6K, 85.1K of that is JavaScript, the built-in prototype.js takes 71.2K. We should take some actions for it.

GZIP the JavaScript and Stylesheet

dailyApps suggests to dynamically gzip the stylesheet and JavaScript to reduce the HTTP download. jotsheet goes even further, a neat method is demonstrated to consolidate all the CSS/JavaScript into one to save the HTTP request.

For normal users, the big bottleneck is the size of prototype.js, and it is most unlikely change unless major version update. So let’s gzip it first and check out the performance boost: Using Dojo ShrinkSafe, the prototype.js is cut to 49K, not bad.

Thanks to the flexibility of VDS powered by Jumpline, I could easily add mod_deflate to Apache, and enable mod_deflate globally to all CSS and JavaScript. Check out the doc for details.

AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE text/css

This helps me to save tens of kilobytes, now the gzipped-shrunk protoype.js is 14.6K only, the overall improvement is gzipped 30.2K versus original 142.0K, that is quite impressive.

Use client-side cache

mod_expires just did the right work, load the module and enable it wherever the content would not change:

ExpiresActive On
ExpiresDefault A2592000

Remove ETag

Use these directive to disable ETag globally in httpd.conf:

Header unset ETag
FileETag None

I get B(87) with cache, A(95) without cache in YSlow performance score. The next step optimization may introduce CDN service, for example, Amazon S3.