Support » Plugin: W3 Total Cache » W3TC breaks my audio downloader

  • Resolved wombatsuit

    (@wombatsuit)


    Hi, W3TC is working well for me except on pages that I have audio download links. Whenever anyone clicks to download an MP3, the resulting file contains only the following text instead of the binary MP3 data:
    <b>Fatal error</b>: Unknown: Cannot use output buffering in output buffering display handlers in <b>Unknown</b> on line <b>0</b><br />

    Here’s the crucial snippet from our download plugin. Is there any way to disable caching for pages served by this plugin. It’s keyed to a trailing “folder” on the url called “/download-audio”

    header("Pragma: public");
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header( "Cache-Control: private", false);
    header("Content-Type: application/force-download");
    header("Content-Type: application/octet-stream");
    header("Content-Type: application/download");
    header('Content-Disposition: attachment; filename="'.$file_name.'";');
    header("Content-Transfer-Encoding: binary");
    $filesize = filesize($full_filename);
    if ($filesize != 0)
    header("Content-Length: ".$filesize);
    ob_clean();
    flush();
    readfile($full_filename);
    exit;

    http://wordpress.org/extend/plugins/w3-total-cache/

Viewing 1 replies (of 1 total)
  • Okay, I figured out a work-around. The problem was coming from the readfile() function since it sends the file to the output buffer. I just disabled output buffering (call ob_end_clean();) before the code runs:

    ob_end_clean();
    header("Pragma: public");
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header( "Cache-Control: private", false);
    header("Content-Type: application/force-download");
    header("Content-Type: application/octet-stream");
    header("Content-Type: application/download");
    header('Content-Disposition: attachment; filename="'.$file_name.'";');
    header("Content-Transfer-Encoding: binary");
    $filesize = filesize($full_filename);
    if ($filesize != 0)
    header("Content-Length: ".$filesize);
    ob_clean();
    flush();
    readfile($full_filename);
    exit;
Viewing 1 replies (of 1 total)
  • The topic ‘W3TC breaks my audio downloader’ is closed to new replies.