Hey everyone.
Thought I should share this method of speeding WordPress up dramatically without much configuration.
This is the caching method used over at Gatsby and any WordPress based client sites I maintain. As the cache is in-memory, it handles surges of traffic very well.
Want to see how it handles? Head over to Gatsby.
Requirements:
I personally use this in conjunction with APC. It should work with other caching methods as well, but your milage may vary.
1. Back your stuff up
Although nothing we're going to be doing will touch your databases and whatnot, it's probably a good idea to make sure you're able to revert to how things were originally. Just incase you completely fudge something up.
In all honesty, you should have robust backups in place already. If not, here's your gentle reminder to get backups set up.
Also - It's not a backup unless you're able to restore it easily in an emergency.
2. Add a Repo
This is genuinely the most taxing part of the process, although it's relatively simple. The issue is that most Linux distros have pretty outdated versions of Redis in their repositories.
Although you could just install the respective .deb/.rpm, it's a good idea to get a frequently updated repository added to your system just incase an exploit is found in Redis.
If you're running Debian Linux I personally recommend you use the DotDeb repository
If you're running a RedHat based Linux distro, I personally recommend you use Remi Collet's repository
Follow the respective instructions on each site!
3. Install Redis
If you're running a Debian based Linux distro
apt-get install redis
If you're running a RedHat based Linux distro
yum install redis
Once installed, you can fire up Redis
/etc/init.d/redis start
OR
/etc/init.d/redis-server start
4. Make WordPress Use Redis
Here's the last step. We're going to need a couple of files to make WordPress interact with Redis.
The idea is that we want to use a new index.php, so that every single valid request hits Redis before asking WordPress to regenerate the page.
To do that, we'll have to move the original index.php
mv index.php backup_index.php
You'll then need to grab predis.php so PHP can interact with Redis
wget http://uploads.staticjw.com/ji/jim/predis.php
Finally, grab the new index.php
wget http://pastie.org/pastes/7953263/text -O index.php
If all goes well, load up your WordPress site and pages should appear. If not, you've probably done something wrong.
Final Statements
Thought I should share this method of speeding WordPress up dramatically without much configuration.
This is the caching method used over at Gatsby and any WordPress based client sites I maintain. As the cache is in-memory, it handles surges of traffic very well.
Want to see how it handles? Head over to Gatsby.
Requirements:
- The ability to follow simple instructions
- Root access to your server (Just incase this is picked up by Google)
- About 15 minutes of your time
I personally use this in conjunction with APC. It should work with other caching methods as well, but your milage may vary.
1. Back your stuff up
Although nothing we're going to be doing will touch your databases and whatnot, it's probably a good idea to make sure you're able to revert to how things were originally. Just incase you completely fudge something up.
In all honesty, you should have robust backups in place already. If not, here's your gentle reminder to get backups set up.
Also - It's not a backup unless you're able to restore it easily in an emergency.
2. Add a Repo
This is genuinely the most taxing part of the process, although it's relatively simple. The issue is that most Linux distros have pretty outdated versions of Redis in their repositories.
Although you could just install the respective .deb/.rpm, it's a good idea to get a frequently updated repository added to your system just incase an exploit is found in Redis.
If you're running Debian Linux I personally recommend you use the DotDeb repository
If you're running a RedHat based Linux distro, I personally recommend you use Remi Collet's repository
Follow the respective instructions on each site!
3. Install Redis
If you're running a Debian based Linux distro
apt-get install redis
If you're running a RedHat based Linux distro
yum install redis
Once installed, you can fire up Redis
/etc/init.d/redis start
OR
/etc/init.d/redis-server start
4. Make WordPress Use Redis
Here's the last step. We're going to need a couple of files to make WordPress interact with Redis.
The idea is that we want to use a new index.php, so that every single valid request hits Redis before asking WordPress to regenerate the page.
To do that, we'll have to move the original index.php
mv index.php backup_index.php
You'll then need to grab predis.php so PHP can interact with Redis
wget http://uploads.staticjw.com/ji/jim/predis.php
Finally, grab the new index.php
wget http://pastie.org/pastes/7953263/text -O index.php
If all goes well, load up your WordPress site and pages should appear. If not, you've probably done something wrong.
Final Statements
- I do not claim any credit for this caching method, all of which goes to Jim Westergren.
- In regards to security, it only displays the cached pages if the visitor isn't logged in - That means that whilst you're logged in pages may load slower.
- To refresh a page's cache, force a page reload (F5). Pages aren't regenerated if you're simply clicking through pages.
Last edited by a moderator: