Fixing Batcache to Send The Correct Content-Type Header

I’m a fan of Batcache, the Memcached-based WordPress full-page cache solution, but I’ve discovered that it ignores the content-type header set when the page is initially generated and re-sends all content with content-type: text/html. I posted a note about this at the WordPress support forums, but then I realized what the problem was: apache_response_headers() doesn’t return the content type, but headers_list() does.

The solution is to replace apache_response_headers() with headers_list() in the code, though headers_list() is PHP 5+ only, so it might be a while before we see a change like this committed. Still, I’ll shamelessly tag Andy Skelton (Batcache’s author) on it.

3 Comments

  1. It’s a shame we can’t rely on PHP knowing the headers sent. That’s why I added the status_header filter. Unfortunately WordPress doesn’t have a similar function for all headers. If you want to patch with a function_exists check, I’ll commit it.

  2. @Andy Skelton: Will do.

  3. [...] Casey Bisson for describ­ing the content-​type patch for Batcache [...]


Comments RSS TrackBack Identifier URI

Leave a comment

 

User contributed tags for this post:

batcache (7) - batcache content type (3) - batcache header (3) - batcache headers (3) - batcache content-type (3) - batcache blogs archived cached not (2) - anmelssex (2) - wordpress status_header filter (1) - memcached batcache (1) - batcached (1) - php ignoring content type header (1) - send music in application contenet-type (1) - correct content type (1) - bisson header (1) - batcache source (1) - wordpress batcache content-type (1) - batcache and nginx (1) - wordpress plugin send header (1) - batcache header issue (1) - batcache wordpress (1) - what is fixing bot in photograhy (1) - batcache plugin (1) - batcache post comments (1) - send correct content type (1) - content (1) -