Tags Posts tagged with "cache"



Most of our WordPress blogs are hosted on Linux Apache server. And there is a guide to speed up your website with Apache .htaccess file tweaks. Saw this one at AllGure.NET for quite some times but did not implement it until now. By the way, this is one of the W3 Total Cache feature ~ “Instant” second page views (browser caching after first page view). But too bad, I enabled it on W3 Total Cache and failed to work. So I stick with AllGure.NET guide, and work like a charm.

“Instant” second page view

Above is the second page view of spBlogger.com. spbloggger.com’s images, CSS, JavaScript are cached at browser. Therefore, only the first line is coming from spBlogger.com and the rest from others like Nuffnang, Facebook, Google, ContextWeb…

If you did not implement it, you will see lot of not modified 304 status codes responded by your web server. You are wasting server CPU resources and user time as browser actually makes a request to web server to request for those files which are not modified. And they should be cached at browser level. So no addition requests to web server. Here are the examples using WebPagetest before and after.

How to speed up WordPress blog with Apache .htaccess?

# Turn on Expires and set default expires to 3 month
ExpiresActive On
ExpiresDefault A7257600
ExpiresByType image/x-icon A14515200

# Set up caching on media files for 1 month
<FilesMatch “\.(gif|jpg|JPG|jpeg|png|PNG)$”>
ExpiresDefault A2419200

# Set up caching on commonly updated files 1 month
<FilesMatch “\.(xml|txt|html|js|css)$”>
ExpiresDefault A2419200

<FilesMatch “\.(ico|gif|jpg|JPG|jpeg|png|PNG|css|js|html?|xml|txt)$”>
FileETag None

# gzip compression
<IfModule mod_deflate.c>
<FilesMatch “\.(js|css)$”>
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/css application/x-javascript text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon

By adding these at .htaccess file, your images will be cached at browser. And CSS, JavaScript, XML and HTML will be compressed by the Apache server before send to browser. However, not all the web hosting can support gzip compression properly. I tried it on my 3 web hosting with same configuration. HostMonster and Just Host do not compress HTML, CSS and JavaScript most of the time. Only HostGator does the compression work perfectly. Wonder why…


HostMonster and Bluehost list out all the slow SQL queries that use more than 1 second query_time in $HOME/tmp/mysql_slow_queries folder. I guess they have poor performance DB server because the other 2 web hosting that I use ~ HostGator and Just Host don’t have it. Anyway, if you see lot of log files there, this mean that you are using quite some CPU resources and getting sooner to get suspended like I did. When you look into these logs, you will find most of them are WordPress standard SQL queries and you can’t do any optimization on the queries themselves. But there are other ways to reduce access to DB server like wp-config.php tweaks.

How to speed up WordPress blog with wp-config.php tweaks?

By adding WP_HOME and WP_SITERUL, WordPress does not need to access to DB server to grab these 2 values every time when header or footer call these for RSS, CSS, JavaScript location on your theme.

define(‘WP_HOME’, ‘http://spblogger.com’);
define(‘WP_SITEURL’, ‘http://spblogger.com’);

WordPress Security Keys. Have it pre-defined in wp-config.php to eliminate WordPress to generate there salts for you if none are provided. Get yours here.

define(‘AUTH_KEY’, ‘xxx’);
define(‘SECURE_AUTH_KEY’, ‘xxx’);
define(‘LOGGED_IN_KEY’, ‘xxx’);
define(‘NONCE_KEY’, ‘xxx’);

Disable post revision function. This will reduce number of rows in WordPress post table == faster page finding and loading. I don’t use it anyway, so I disabled it.

define(‘WP_POST_REVISIONS’, false);

Be sure to check out AllGure.NET post for more info.


As I said, HostMonster and Bluehost are famous with CPU Throttling. Therefore, a WordPress cache plugin is a must installed on their hosting. My account got suspended even I am using WP Super Cache for quite some time. After do a comparison between WP Super Cache and W3 Total Cache, I decided to use W3 Total Cache as it is better than WP Super Cache.

HostMonster CPU Limiting Factors (Throttling)

I am using W3 Total Cache v0.9.1.3 on WordPress v3.0.4. W3 Total Cache is working out of the box with default settings. However, I discovered HTTP (gzip) compression is not working on HostMonster and Just Host most of the time. Therefore, CSS, JavaScript and HTML are not compressed with gzip. Only HostGator works perfectly. Must be web hosting issue.

On the other hand, W3 Total Cache failed to cache other object like images with expires header, cache control header and entity tag (eTag). None of the 3 web hosting that I use is working. So no “Instant” second page views (browser caching after first page view). Besides, its minify function might broke your other plugin’s CSS and JavaScript. I tried on PrettyGirl2u.com and it failed totally. So use it carefully.

By the way, I enabled database caching via disk. It does reduce some CPU resources on HostMonster. But it can’t help much if your visitors or yourself is ‘touching’ DB server directly by posting comments or editing posts. As you can see picture above on the last 1 hour, CPU usage spiked because I was replying few comments.

Overall, W3 Total Cache is a must installed plugin on WordPress blog. Not perfect but worth to install. And do tweak it until you get the best performance out of it.

Download W3 Total Cache WordPress Plugin here.


Does your blog have lot of Digg or Stumble Upon traffic hits? And your web hosting cannot take that hits and crash. Fear no more. WP Super Cache WordPress plugin comes to rescue.

HostMonster CPU Limiting Factors (Throttling)

Some said that HostMonster CPU Limiting Factors (Throttling) data is not accurate. I tried WP Super Cache for 1 day. It does reduce CPU usage a little bit but not much. Why? My blogs don’t have many hits from SU and Digg. So far, I only got around 80 cache pages. Let’s monitor when I get more traffic hits.

Download WordPress plugin ~ WP Super Cache here.


I was using Google Gears on Firefox 2.x long time ago until a Google Gears developer broke some codes that crash with Firefox. And after upgraded to WordPress 2.8, I did not see the ‘Turbo’ sign anymore. I thought Google Gears is still not ready for Firefox 3.5 yet. Haha… I was wrong. The option to turn on Google Gears is at the WordPress Tools section all the while (I don’t even notice there are ‘Tools’ section until I read from a plugin readme 😛 ).


Okay, what is Gears? Gears is an open source browser extension that lets developers create web applications that can run offline. Gears provides three key features like…

  • A local server, to cache and serve application resources (HTML, JavaScript, images, etc.) without needing to contact a server
  • A database, to store and access data from within the browser
  • A worker thread pool, to make web applications more responsive by performing expensive operations in the background

Your blogging time will be shortening with this Google Gears enabled. It will cut short the loading time, but you still need time to think what to write and type. Try it and believe it. 😉