Using WP-Cache on GoDaddy (500 Error)

Posted by admin on July 21st, 2008

This post has nothing to do with online dating. It has to do with a particular error, 500 Internal Server Error, when using WordPress and the plug-in WP-Cache on a GoDaddy shared server. My hope is that others who experience the issues I had might find this post and (hopefully) will be able to avoid the hassle I went through!
The Problem
WP-Cache is a plug-in for WordPress that allows web pages to be served quicker by requesting data from the database far less often. However, when this plugin is enable on GoDaddy a strange thing occurs: every other time you load the page you get a 500 Internal Server Error. When this occurs, I suspect most WordPress users on GoDaddy simply disable the plug-in. Unfortunately, if their WordPress site starts to generate traffic, GoDaddy will complain that they are creating too much of a load on the database server. So there appears to be a catch-22 in that GoDaddy doesn’t support the technology that would allow its customer to avoid the very problem the company is complaining about.

The Solution
1. Download the wp-cache-phase1.php in /blog_home/wp-content/plugins/wp-cache/ from your web server.
2. Edit the file by finding the lines:
foreach ($meta->headers as $header) {
header($header);
}

3. Replace these lines with the following:
foreach ($meta->headers as $header) {
if (strpos($header, ‘Last-Modified:’)===FALSE) {
header($header);
} else {
// do nothing - makes GoDaddy angry
}
}

4. Upload the wp-cache-phase1.php to your web server and try refreshing some cached pages.

The Warning
As you will discover if you read below, I’m not very confident in what I am doing and I’ve stumbled through most of my testing. Implementing this change, while it may fix wp-cache, may create other problems. It may not, though. I really have no idea. Also, I was having problems with a header for Last-Modified - I have no clue whether others are going to see the same issue. My solution may not be a solution at all. All I can say is that in my opinion, it appears to work. At any rate, use this at your own risk!

The Explanation (From a Novice)
I am absolutely new to WordPress, PHP, Apache, etc. I am a Java developer by profession so I can read the code but I suspect many of the steps I took, which are described below, were an absolute waste of time created by my ignorance. My hopes are that an expert may be able to review this and explain better why the problem occurs (so I’ve included all the steps I’ve taken working on this issue). Also, if you are also a novice and are interested in understanding some of what I discuss, it would be best to review the readme.txt included with the wp-cache plug-in.

When I started reading about WP-Cache I immediately started seeing articles (for example, here and here) regarding problems when using GoDaddy. Depressing me even further: most of the responses I found seemed to simply write-off the problem as an unaddressable GoDaddy issue. Honestly, after seeing so many people state so convincingly that any 500 Internal Server Error is GoDaddy’s problem and nothing can be done to fix it, I was inclined to simply believe that there was no hope.

Regardless, I decided to give the plug-in a try hoping that maybe there was some difference between my GoDaddy server and everyone else’s (heh). The install went well and even the first time I loaded a page I could see it appear in my cache. My excitement lasted about 5 seconds: after a refresh I was viewing the dreaded 500 Internal Server Error. I fooled around with some settings on the plug-in itself but it did no good. Things appeared to be broken. Before giving up, I decided to view the source of the 500 Internal Error page, believing there might be some clue there. To my surprise, the entire code of my page was in the source! In other words, I was not seeing the expected 5 lines of source for the 500 error but rather 100+ lines of the page I actually attempted to load. This was exciting to me because now I could add some debug and try to determine where the problem was occuring.

My first thought was that if the page was loading, the first part of (wp-cache-phase1.php) was working and it must be the caching of the page to disk (wp-cache-phase2.php) where the problem existed. I found the line in wp-cache-phase1.php that called phase2 and commented it:
// wp_cache_phase2();
I reloaded my previously cached page but the problem persisted. This was a good thing, though, as I found the code in phase1 more understandable.

At this point, I started commenting out different sections of the phase1 code. I discovered all my problems disappeared when I commented out the foreach loop that creates the headers. I added logging to this section and found that I had two headers:

  • Last-Modified: Sat, 08 Sep 2007 13:31:29 GMT
  • Content-Type: text/html; charset=”UTF-8″

Then, instead of using the foreach loop, I manually tried each of the headers individually. Testing Content-Type went fine but testing Last-Modified and the 500 errors reappeared. At this point, I created a new php file to test the Last-Modified header (you can view the source here). I named this test.php and loaded it successfully (you can test it yourself if you would like. When I reloaded it, though, the 500 error occurred! At this point, I read a little on the Last-Modified header and decided to disable the cache on my web browser. Now the problem disappearred no matter how often I reloaded…so the problem seems somehow related to when a browser is deciding if it needs to request to redownload files (I’m out of my league at this point).

The Help?
And now, I am at a loss. I can implement wp-cache but only if I explicitly ignore Last-Modified headers. Will this create problems? According to this document, I should always send Last-Modified when able. I restored the old code to view the headers when the page displays properly versus when it does not (500 error) and they are identical:
Date: Sat, 08 Sep 2007 13:59:19 GMT
Server: Apache
Last-Modified: Sat, 08 Sep 2007 13:31:29 GMT
Keep-Alive: timeout=15, max=99
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=”UTF-8″

200 OK

The fact that the 500 error occurs intermittently (normally every other time) is also very confusing. How is an identical Last-Modified header causing problems half the time? And why does disabling cache on my browser (Firefox) cause the problem to disappear?

If any experts out there want to weigh in on this, I’d love for you to do so. For now, I’m going to continue to use my “fix” by ignoring the Last-Modified when serving cached pages.

30+ AJAX-Plugins For WordPress

Posted by admin on June 13th, 2008

AjaxWP - Adds AJAX to all aspects of your WordPress site speeding up the load times.

Alexa Rank - Display your Alexa rank with pride.

Ajax Comment Preview - Allows readers to preview their comment before submitting.

asTunes - Retrieves data from your Audioscrobbler/last.fm profile and posts it as a list on your blog.

Codebox - Side scrolling box for displaying code snippets.

Crossroads - Adds thumbnails and comments from your Flickr account.

FireStats - Full featured statistics including referrers and popular pages.

Google PageRank - Allows you to display your Google Page rank on your blog.

Hardened-Trackback - Generates a single use trackback to help fight trackback spam.

imgViewJX - Refreshes an image on your main page from a selected directory.

Live Spell Checker - Adds a spell checker to the admin area to check your posts with.

Plug ‘n’ Play Google Map - Adds any post you make with longitude and latitude to a Google Map on a separate page. Very useful for blogs writing restaurant reviews or about events.

Wordpress Mailing List - Have a mailing list? Let readers subscribe and unsubscribe simply from the front page of your site.

WP e-Commerce - Adds a shopping cart to your WordPress powered site.

WP-Polls - Adds fully customizable polls for your readers to take.

WP-Post Ratings - Allows readers to rate your posts.

Zorpia That’s Hot Box - Allows visitors to send posts they like Zorpia.com and vote on their favorite articles.

AJAX Comments 2.0 - Auto updates the comments page with no full reload, much smoother commenting than the older full reload system.

AJAX Google Video Search - Search Google Video without having to leave your favorite blog.

AJAX Shoutbox - Realtime conversation with sound to alert of new messages.

Cool Weather - Allows visitors to see the weather forecast for any area they define.

Currency Converter - Adds a real time currency converter to the page with data pulled from Yahoo Finance.

Google AJAX Search - Allows you to set search for just the contents of your site and the web, or another option allows for search of a second site such as your Flickr account.

Google MapSearch Widget - Allows readers to search Google Maps without ever leaving the page.

Gregarious - Social bookmarking plugin that adds Digg, Reddit, Feedburner FeedFlare buttons and more.

Hottaimoijiruna - Adds a self-updating clock to the site for a timezone defined by the blogger.

Inline Ajax Comments - Hides comments until the user clicks on them, and then they fade-in with no reload.

Inline Ajax Page - Allows readers to see a snippet of a post, click a button and the remainder will appear without going to another page.

Tagboard Widget - Adds an auto-updating tagboard to your site that displays new messages as they are posted.

Units Converter - Converts hundreds of different units of Length, Area, Volume, Weight / Mass, Speed without reloading the page.

WP Movie Ratings - Combines data from IMDB with the bloggers movie review and lets the readers add their own rating instantly.

XDTalk - Allows real-time conversation between registered users.


Copyright © 2007 SEO WordPress Themes. All rights reserved.