• Resolved mjb2000

    (@mjb2000)


    I am running latest versions of everything on nginx/mariaDB/ubuntu_20.04.

    I have noticed an issue when I try to use CSS/JS minify and enable gZip compression of CSS/JS.

    Steps to re-produce…

    1. Save & Purge W3 Cache settings
    2. Update the media query string
    3. Clear the minify cache
    4. Clear the page cache
    5. Restart nginx
    6. Clear the browser cache
    7. Refresh the page in the browser

    All CSS and JS files will return a “ERR_CONTENT_DECODING_FAILED” error. If you reload the page, everything will be perfect.

    If you navigate to another page which needs some different CSS/JS then this will also fail if it is the first time that CSS/JS has been called.

    I wonder in this is some sort of “race situation”, perhaps with W3TC trying to serve a minify/abc123.css_gzip file before it has been created?

    This problem is made much worse if you use a CDN because this first-time issue is the one that gets cached on the CDN, so if you are using a CDN then every page will fail, even when reloaded because the faulty version has been cached.

    • I have tried using “combine only” and this makes no difference – same problem.
    • If I turn off compression then everything works OK, so there is no particular issue with minifying my theme’s CSS/JS
    • If I turn off minify and just leave compression then everything also works OK. So there is no issue with gZip compression.
    • I have tried modifying my core /etc/nginx/nginx.conf so that gZip is not enabled by default. Therefore all gZip declarations are being created by W3TC in the /var/www/worpress/nginx.conf
    • I am pretty sure I saw a similar problem on an apache based installation I was also working on, but that project got dropped
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @mjb2000

    I am sorry about the issue you are experiencing and I am happy to assist you with this.
    Does the issue persist if you just Update the media query string and check your website or Clear minify cache?
    Also can you please share your website URL?
    Thank you!

    Thread Starter mjb2000

    (@mjb2000)

    Hi Marko

    I hadn’t spotted the empty minify cache before – That seems to be the simplist way to trigger the issue. As soon as I hit that and then reload the page in a browser I see the error.

    BUT – I guessed from your response that this is not something you have seen before so I started disabling plugins one-by-one and found that a custom plugin I wrote seems to be causing the problem. I have probably not done something in line with the correct way to write plugins (I don’t really know what I’m doing).

    So I’ll work on fixing my plugin (all it does it tweak a few WooCommerce things and add some CSS, so I might move it to the theme functions.php).

    I’ll write back here once I realise what the problem was.

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @mjb2000

    Thank you for the information! YOu are right when you say that this was the first time I’ve seen this kind of issue.
    Thank you for letting us know that you found the source of the issue and what causes the conflict and please let us know what the problem was with the mentioned plugin.
    Thank you!

    Thread Starter mjb2000

    (@mjb2000)

    Doh… This was the problem with my plugin… White space after the final php close tag ?>

    
    987     }
    988 ?>
    989
    990
    

    I have to deleted lines 989 and 990 and it then worked.

    It does seem strange the the minify+compression was working after first-load though.

    • This reply was modified 4 years, 6 months ago by mjb2000.
    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @mjb2000

    Thank you for the information. I am glad to know you found where the issue was.
    Yes that is interesting but the important thing is that s working now.
    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Minify + gZip = error on first load only (race situation?)’ is closed to new replies.