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.
- The topic ‘Found possible issue in lib/W3/Minify.php’ is closed to new replies.