Support » Plugin: W3 Total Cache » Found possible issue in lib/W3/Minify.php

  • It’s a while I am investigating why, in manual minification mode, I get sporadic:

    Recently an error occurred while creating the CSS / JS minify cache: Unable to cache remote file: “http://www.domain.tld/?bfa_ata_file=js”

    That comes from a most famous theme called Athaualpa.
    That theme, like many other scripts, uses dynamically generated JS and CSS.

    Now, I am pretty sure the W3 TC minify DOES manage those files. The URL for my domain has a MD5 of 49518a4e54e5254cfa2b9159e22c9b1e.
    I have dissected Minify.php a bit and guess what, it ends generating a file including the MD5 in the name but it’s labelled as .old.

    The content is exactly what’s returned by calling the dynamic JS URL:

    //<![CDATA[

    /* JQUERY */
    jQuery(document).ready(function(){
    ….

    So, W3 TC can work with those files, it just does not work reliably with them. I noticed that:

    function _precache_file($url, $type)

    ends up calling

    w3_download($url, $cache_path);

    I think the function sometimes fails (digging in http.php did not show a retry mechanism). Once it fails it stops retrying and the JS file becomes unavailable with the obvious consequences.

    Since the same template creates dynamic CSS files as well, it’s easy to see the consequences of this mechanism: the whole site appears broken!

    A first fix imo should be:

    if (download failed) {
    rename .old file back to the original;
    set timer to refresh to 5 minutes
    }

    That would guarantee the users would see an correct website even with sporadic http GET errors.

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

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

    (@dfumagalli)

    I have also found the use-case for implementing the suggested fix.
    I have found out that WP’s cron may get errors like:

    There was a problem spawning a call to the WP-Cron system on your site. This means WP-Cron jobs on your site may not work. The problem was:
    Resolving host timed out: http://www.domain.tld.

    This means that in case of shared hosting (the machine giving me issues is on a shared hosting, they are less than perfect) it’s possible some cron “shots” don’t go off. This means that moving files to “.old” should not an unchecked process, they should only be moved to .old after their relevant updated file has been succesfully re-generated.

Viewing 1 replies (of 1 total)
  • The topic ‘Found possible issue in lib/W3/Minify.php’ is closed to new replies.