Wp-Super-Cache and 500 errors ("Premature end of script headers")
WordPress 3.6.0 and 3.6.1, Multi-Site, WP Super Cache 1.3.2
Apache, PHP Version 5.2.17, [HTTP_ACCEPT_ENCODING] => gzip, deflate
This is not really a wp-super-cache bug, but it shows up in wp-super-cache as mysterious pages giving 500 Server Errors or partially blank pages.
Note: Other sypmtoms: WordPress Update hangs, WordPress plugin update hangs, and PHP Unzip hangs [e.g. $zip->extractTo($path.’/folder’) or copy(“zip://”.$zipFullPath.’#’.$filename, $destPath.$destName); ]
So, it is likely a PHP Unzip bug (in an Old version of PHP) that produces no error code, no log messages, and has no direct PHP method of testing it.
WP Super Cache configured to use PHP caching, Cache Test: Successful.
Change to .htaccess caching, Plugin section of /wp-admin/options-general.php?page=wpsupercache&tab=settings is blank (WordPress menus on left do display).
I recommend having 644 rights on .htaccess, no script should be allowed to modify a key security file!
Manually added WPSuperCache lines to .htaccess. No change in WPSupercache display.
Manually edit /public_html/wp-content/wp-cache-config.php, change $wp_cache_mod_rewrite = 1; to $wp_cache_mod_rewrite = 0; (restores WPSuperCache settings page display; Advanced Tab has “Use PHP to serve cache files” selected)
.htaccess still has WPSuperCache lines. Cache test successful.
On Advanced tab, Add “Compress pages so they’re served more quickly to visitors. (Recommended)”.
Fetching [URL] to prime cache: OK
Fetching first copy of [URL]: OK (1.html)
Fetching second copy of [URL]: OK (2.html)
One or more page requests failed:
Page 1: 500 (Internal Server Error)
Page 2: 500 (Internal Server Error)
The pages do not match! Timestamps differ or were not found!
Uncheck “Compress pages so they’re served more quickly to visitors. (Recommended)” on Advanced tab.
Cache Test successful
So, there are versions of PHP out there that have bugs in Unzip, so unzipping hangs or returns 500 Server Error (specifically, “Premature end of script headers” in $_SERVER[‘REDIRECT_ERROR_NOTES’] ). Unzip returns nothing (fails with a time-out error?), so the “cached” page is likely 0 bytes, so there are no HTML page headers sent.
Donncha: I recommend modifying wp-super-cache: testing when someone attempts setting “Compress pages…” whether Unzip works (the Cache Test returning 500 Error), and let the user know if it fails, and prohibit use of compressing if it fails.
I recommend testing for cached page returned with 0 bytes, and serving the uncached page (or un-zipped page) instead — with error log message.
Looks like this PHP bug might have been fixed in PHP Version 5.3.4 09-Dec-2010 – “Fixed crash in zip extract method” http://www.php.net/ChangeLog-5.php#5.3.4
Others probably have been affected by the same PHP Unzip bug:
- The topic ‘Wp-Super-Cache and 500 errors ("Premature end of script headers")’ is closed to new replies.