WordPress Fatal error: Unknown: Cannot use output buffering in output buffering display handlers in Unknown on line 0

How I’ve beat the php mysterious fatal error unknown in Wordpress caused by caching plugin WP Fastest Cache

November 7, 2019

This problem was caused by WP Fastest Cache plugin the famous cache plugin with over 1 million active installations. Disabling all the options and testing one by one I’ve found that the problem happens when I flag one of these options:

  • Minify Css
  • Combine css files
  • Combined js files
list of the options of the wp fastest cache plugin

These options are critical in caching plugins because they do complex and potentially dangerous operations that modify the CSS files and Javascript files shrinking them. The minification process opens the CSS and reduce it to the minimal code necessary. This means that the code is cleaned from comments, cleaned from useless spaces, “;” chars, tabs, new lines… For javascript minification the reduction is even more heavy because it changes also the names of the functions to reduce even more (the result is normally not easy to read by a human).

All the CSS reduced files (minified is the correct term) are then chained into a one single file to reduce the number of HTTP calls. The same is made by combining the Javascript minified files and making just one JS file.

This work is really awesome and very useful. But…

It may happen that the minification process brakes everything and causes the mysterious error: Fatal error: Unknown: Cannot use output buffering in output buffering display handlers in Unknown on line 0.

These options normally works really fine, I’ve uses WP Fastest Cache plugin on many WordPress installations, I trust their developers!

I’ve found that the problem is within the script inclusion, I use inclusion directly in the footer.php or in header.php of my themes, like these:

<script type="text/javascript" data-src="<?php
   bloginfo("template_directory");
?>/js/main.js?v=07/11/2019"></script>

And the problem happened due to the “/” chars in the version parameter (I sometimes put the date as version parameter). Removing the “/” solved the issue.

I don’t know if someone else ever found this problem.

Author

I'm a software engineer, an everyday web developer and a maker. I usually build sites with PHP, within or without WordPress. I build Internet of Things with Arduino and ESP8266. I'm the founder of Rockit.it and Dailybest.it and I'm actually the Chief Technical Officer of Better Days web agency.

Comments on “WordPress Fatal error: Unknown: Cannot use output buffering in output buffering display handlers in Unknown on line 0”

Leave a Reply

Your email address will not be published. Required fields are marked with an *

Recommended

Fix for WP SUPER CACHE home not refreshing

WP SUPER CACHE is one of the most used WordPress plugin for cache, but probably there is a small bug…

December 1, 2014

W3tc plugin feed problem

When your WordPress site has a great number of requests it could happen that your server can’t handle all the…

October 22, 2012

Modify the language attribute based on category in WordPress

How to modify the language attribute in your Wordpress theme using a specific value

November 7, 2019

WordPress Gutenberg doesn’t parse Istagram oembed url

Sometimes Instagram embed doesn't work, why?

November 4, 2019

Stop sending email to new user in WordPress admin registration

A code snippet to prevent WordPress to send notification emails when you manually create new users. It uses a pluggable function.

November 1, 2019

A new avatar generator for WordPress with get_avatar and Flathash

Brand new avatars for WordPress Gravatar service

April 7, 2017