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

Novembre 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" loading="lazy" 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

PHP expert. Wordpress plugin and theme developer. Father, Maker, Arduino and ESP8266 enthusiast.

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…

Dicembre 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…

Ottobre 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

Novembre 7, 2019

WP Gutenberg notes

Collection of notes and thoughts on Wordpress Gutenberg blocks development.

Gennaio 9, 2023

Test page for Bright Links plugin

To test the plugin hover your mouse to a link, or tap the link on mobile device.

Dicembre 4, 2022

Updating a metabox after Gutenberg updates

When press on "Update" refresh a custom metabox under gutenberg editor.