WordPress: A Tip About WP Super Cache

First of all, let me apologize for having been so absent over the last few weeks. As you may or may not have heard already, we just launched the new website at University of Mary Washington, and things have been hectic trying to put the final pieces into place.

One of those final pieces was to get WP Super Cache up and running on the site, in order to keep our server from overloading. When we first launched, I didn’t realize that we didn’t have the plugin configured properly, and our various plugins and theme functions really started to drag things to a crawl.

After doing a lot of digging and debugging, I found that WP Super Cache was ignoring cached files throughout our server because they all included GET variables.

The next step was to find out what GET variable(s) was/were causing the problem, so I headed on over to our development server and threw in some debug code to output the contents of $_GET in the footer of every page. It turned out that the code I’d created to implement the Google Custom Search Engine on our site was setting a default choice for which search engine to use, and was setting that default choice as a GET var. I fixed that minor issue and WP Super Cache started working like a champ.

Within Google’s Webmaster Tools, I ran a test on the production server to see how long it took Google to retrieve our home page before and after I made this tiny little change. Before (when pages were not being cached properly), it took approximately 4,400 milliseconds (that’s over 4 seconds) for Google to retrieve the home page. After the change (with pages being cached properly now), it took 97 milliseconds to retrieve the page (that’s less than one-tenth of a second). That’s a ~98% reduction in the amount of time it takes to serve the pages.

Conclusion

So, if you’re using WP Super Cache on your WordPress site, you should do the following things:

  1. Use the Cache Tester that’s built into the “Simple” tab on the WP Super Cache options page to make sure your page is being cached properly.
  2. If you find that it’s not, enable the Debug option (in the “Debug” tab on the WP Super Cache options page) to see if you can find out why it’s not being cached.
  3. If you see anything about WP Super Cache exiting because of a GET variable, use a script to dump your $_GET array into your pages somewhere (I hooked into the wp_print_footer_scripts action, since that way I could make sure I’d already run through just about everything there was to run through), and see what turns up. Hopefully you’ll recognize the GET var that’s being set, and be able to figure out where to change it.
Also, since we’re using Analytics to track cross-domain requests, I made some changes to the way those requests are tracked; but I will post about that in another post.

Post Your Comment

Your email address will not be published.