Timthumb.php NetworkError 400 Bad Request

Timthumb was giving the WordPress error NetworkError: 400 Bad Request.

More fully this error showed as:

NetworkError: 400 Bad Request - http://10.0.0.1/mysite.co.uk/wp-content/themes/apples/scripts/timthumb.php?src=http://10.0.0.1/mysite.co.uk/wp-content/uploads/2014/01/bananas.jpeg&h=65&w=65&zc=1

Searching on the Internet for possible causes of this error I found that timthumb requires a cache directory.

The file timthumb.php, most likely included with your theme, but possibly also included with a plugin, has a reference to the cache location. The error above shows an example of its inclusion within a theme. Listed at the end of this article are other suggestions.

Download the file or open in your control panel, if available, and search for the reference to the cache directory. It may look similar to:

if(! defined(‘FILE_CACHE_DIRECTORY’) ) define (‘FILE_CACHE_DIRECTORY’, ‘./cache’);

There are suggestions that the cache directory should have 777 permissions. 755 is preferable, as 777 leaves the  directory wide open to access.

Historically there have been security issues associated with the use of timthumb. You may consider it better to forgo the perceived benefits. As an example, viewing the stats for a website its not unusual to find failed 404 page searches, looking for the inclusion of timthumb on a website:

/wp-content/themes/wstheme/timthumb/timthumb.php
/wp-content/themes/wstheme/classes/timthumb.php
/wp-content/themes/wstheme/functions/timthumb.php
/wp-content/themes/wstheme/lib/scripts/timthumb.php