• Resolved leadhos

    (@leadhos)


    Hello,

    Just experienced some weird cache problems. Related to WP Super Cache, but not necessarily a bug. Just want to confirm the actual cause, so it does not happen again.

    Summary

    Site is proxied through CloudFlare. PHP 7.4.33. Apache virtual host, Ubuntu Server 22.04.

    Compress pages so they’re served more quickly to visitors. (Recommended): Enabled

    When navigating to pages on my domain, it triggered a .gz download in Firefox. Probably would have in Chrome too – but use Chrome daily, so browser cache probably masked the problem.

    Rollback to default theme did not solve the problem, nor disabling Autoptimize (which should not serve gzip anyways). Clearing WP Super Cache did solve the problem, for now.

    Detailed

    Allright, as stated in the summary. Suddenly one of our sites started serving .gz files instead of the actual webpage. Analyzed file online (not locally in case of injected files). Contents (one file) inside .gz, with no file extension, does indeed contain the cached page.

    As per documentation:

    • Cache files: Both wp-cache-config.php and advanced-cache.php are present in ../wp-content/
    • wp-config.php: define( ‘WP_CACHE’, true ); present in wp-config.php, before require_once(ABSPATH.’wp-settings.php’);
    • php.ini: zlib.output_compression = Off
    • mod_mime, mod_headers and mod_expires: All enabled

    Extra cache control, htaccess:

    <FilesMatch "\.(js|css|jpg|gif|png|pdf|swf|svg|svgz|ico|ttf|ttc|otf|eot|woff|woff2|webp)$">
    <IfModule mod_headers.c>
    ExpiresActive On
    ExpiresDefault "access plus 6 month"
    Header set Cache-Control "public, immutable, max-age=15780000, s-maxage=15780000"
    Header set Access-Control-Allow-Origin "*"
    </IfModule>
    </FilesMatch>

    Figured it was a cache problem, obviously. Inspected response headers. Browser does as instructed by content-type when error occurred (download gzip), but obviously not wanted. Relevant:

    • Content-type when error occurred: application/x-gzip
    • Content-type after clearing cache, back to normal: text/html; charset=UTF-8

    Suspected problem

    • Content-encoding: zstd – must be CloudFlare.
      • Have other websites running WP Super Cache (same server and setup), where encoding is gzip as expected. Those are not proxied through CloudFlare.
    • mod_deflate: Enabled – but zlib compression disabled. Either way, never had a problem with that for 5 years.

    So… Any ideas? I suspect conflicting caching between WP Super Cache / CloudFlare, or conflict with mod_deflate.

    Solution may be as simple as disabling “Compress pages so they’re served more quickly to visitors“?

    Regardless of solution, also want input on why content-type was served as application/x-gzip. Can’t see how CloudFlare would affect exactly that.

    Would very much like to get to the bottom of this, so it does not happen again. With local browser caching, it’s hard to know when these kind of errors occur.

Viewing 4 replies - 1 through 4 (of 4 total)
  • I believe I have also been experiencing a similar problem, with pages being “downloaded” rather than displaying. For now I’ve disabled caching, but would like to know if this is a plugin issue.

    Plugin Support Alin (a11n)

    (@alinclamba)

    Hi @leadhos,

    Thank you for the detailed explanation! Based on what you’ve shared, it does sound like there may be a conflict between WP Super Cache and Cloudflare’s handling of cached and compressed files.

    The best course of action to prevent this from happening again would be to disable the “Compress pages so they’re served more quickly to visitors” setting in WP Super Cache. Since your site is proxied through Cloudflare, the additional compression from this setting is likely redundant and could be causing the issue you’ve described.

    Cloudflare already handles compression very efficiently, so disabling this setting in WP Super Cache should resolve the content-type issue you experienced and minimize the risk of similar problems in the future.

    If the issue persists or you notice any unexpected behavior, feel free to share more details, and we’ll be happy to help further!

    @girlswithguns per the forum guidelines, even if the issue appears to be similar, please open a new support thread so we can handle them individually. Thank you!

    Regardless of solution, also want input on why content-type was served as application/x-gzip. Can’t see how CloudFlare would affect exactly that.

    This plugin sets the content-encoding to gzip here, so maybe something else on your server is setting the content-type. However, about 15 years ago something similar was reported and I added extra checks on the homepage. There’s a check for x-gzip here because of it. I could never figure out what caused the problem.

    Plugin Support Stef (a11n)

    (@erania-pinnera)

    Hi there, @leadhos,

    It’s been more than one week since the last interaction in this thread, so I’m going to mark it as solved for now. If you have any further questions or need more help, you’re welcome to open another thread here. Cheers!

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.