• I have a PHP file that loads the WordPress core, ie:

    require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php' );

    This file delivers a large video (mp4) file from an Amazon S3 bucket using the readfile() PHP function.

    I have these lines of code in the file:

    define('DONOTCACHEPAGE', true);
    define('DONOTCDN', true);

    I have entered the file from the do not cache list in multiple places in the W3TC settings in the WP backend. ie:

    Never cache the following pages:
    video\.php*

    Under the CDN settings link.
    Rejected files:
    video*

    I have also tried:
    video.php*
    video\.php*
    (the exact URL including parameters)

    I am still getting this error:
    PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 105583089 bytes) in /httpdocs/wp-content/plugins/w3-total-cache/lib/W3/Plugin/Cdn.php on line 244

    At first I thought it might be a PHP memory issue, so I upped the memory limit from 128M to 256M, but still got the error.

    I tried commenting out the wp-load.php call, and it worked without issue — so I’m pretty certain that W3TC is trying to do CDN functionality on this huge file (500+ MB) and it’s killing the script.

    Is there something I am doing wrong with disabling video.php from being cached in W3TC? Any other tips?

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

Viewing 1 replies (of 1 total)
  • Thread Starter xzistance

    (@xzistance)

    So I figured out how to get my video.php script to work. I had to include this statement before the wp-load include. It was the only statement that made a difference to stop W3TC from attempting to cache the page and breaking it:

    define('WP_ADMIN', true);
    require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php' );
Viewing 1 replies (of 1 total)
  • The topic ‘Disabling all caching for specific page that delivers content via PHP readfile’ is closed to new replies.