Subscribe via

Automatically Turn on WP-Cache During Traffic Storms

I am a semi-fan of WP-Cache. On the good side, it reduces strain on apache by staticising WordPress pages. On the bad side, it messes with my site statistics and makes development hard (I always forget that the page I’m working on is being cached). I like my statistics, but what if I suddenly get a traffic storm? If my site gets dugg, there is no time to worry about statistics. I would need all the help I can get to serve pages efficiently. This is why WP-Cache should be off by default and automatically turned on during traffic storms.

A lot of WordPress optimization techniques I use for this blog were taken from the awesome tutorials at TurbochargedCMS. One of the coolest technique on the tutorial was the WP-Cache on demand section. The tutorial gives complete instructions on how to set it up a monitoring system to automatically turn WP-Cache on if the server response time is too long.
The system is really just a couple of useful scripts and cron.

The first script (Bash shell script) is used to comment and uncomment the following line in the wp-config.php file, which effectively disables/enables WP-Cache:

define ('WP_CACHE', true);

The second script (written in Python) is used to check how long your website takes to load. If the load time takes longer than expected, then the python script calls the bash script to enable WP-Cache. The python script then goes to sleep for an hour. When it wakes back up, it will call the bash script again to turn WP-Cache off.

After the scripts are set up, all you have to do is cron the python script to run every minute and you are done. Now I’m pretty confident that my old machine can handle being dugg. The only bottleneck for me now is my ISP (SBC yuck).

5 Responses to “Automatically Turn on WP-Cache During Traffic Storms”

[go to last comment]
  1. p’bonn your blog is sooo warm and cozy. I am gonna hang around here more often now lol.

  2. Ty Bone

    Sometimes I have the blog open just to make my eyes feel better.

  3. Falling Back to a Low-Bandwidth Theme During Traffic Storms | OMNINOGGIN

    […] building on top of my post about Automatically Enabling WP-Cache during heavy load, so you should go read that first if you haven’t done so […]

  4. WP-Super-Cache Released! | OMNINOGGIN

    […] Finally, an easy way to enable gzip and WP-Cache. The best part of all of this is that my automatic WP-Cache enabling method still works for this plugin since it was built on top of WP-Cache2. I encourage everybody to […]

  5. WP-Cache, the Untold Way to Set It Up « OMNINOGGIN

    […] Hello there! If you are new here, you might want to subscribe to the RSS feed for updates on this topic.Powered by WP Greet BoxWP-Cache is a WordPress plugin that improves your WordPress speed by caching a static version of each dynamic page request and deliverying that static version for subsequent requests to that page. This in combination with WordPress internal cache, Apache cache, eAccelerator op code cache, and Varnish proxy cache provides the ultimate setup to combat traffic storms if your article gets dugg. *Note* that there is also a method that helps you turn on WP-Cache on demand (only during traffic storms), but I will discuss that in a later article. […]

[go to first comment]

Leave a Reply