• Resolved Jayme Edwards

    (@jcedwards76)


    Hello,

    I’m using the following:

    • WordPress 5.9
    • WebP Converter for Media 4.1.2
    • W3 Total Cache 2.2.1
    • Roots bedrock (where website files are placed in[mysite]/web/app and wordpress files are in [mysite]/web/wp).

    As you’ve read in other threads, W3 Total Cache can put your uploads in Amazon S3 to offload them from your server. When I have the CDN to S3 turned off, everything works as expected and I get requests for my images returning to the browser with WebP response headers (even though the original filename is being served) when viewed through Chrome DevTools.

    As soon as I turn on the CDN in W3 total cache, and then ask it to sync my uploads with S3, it uploads my media files but not my WebP converted versions. This then results in the images being served via s3 properly, but the WebP redirection doesn’t happen and I get the original files (albeit served off the CDN).

    My filesystem is setup with [mysite]/web/app as the root, [mysite]/web/app/uploads containing the originals, and [mysite]/app/uploads/uploads-webpc as the webpc upload folder. The strange thing is there is another uploads folder *within* uploads-webpc containing the actual webp files. I.e. [mysite]/app/uploads-webpc/uploads.

    I’m looking for help with how to get w3 total cache to place the webp versions in S3, and the redirection to work properly with it as a CDN. I read all through the threads here and couldn’t seem to find a clear example of this case working – though I may have stepped over it by accident.

    Here are my wordpress hooks in functions.php related to WebP converter for media.

    add_filter('webpc_site_root', function ($path) {
        return dirname(ABSPATH);
    });
    
    add_filter('webpc_site_url', function ($path) {
        return home_url();
    });
    
    add_filter('webpc_dir_name', function ($path, $directory) {
        if ($directory !== 'uploads') {
            return $path;
        }
        return 'app/uploads';
    }, 10, 2);
    
    add_filter('webpc_dir_name', function ($path, $directory) {
        if ($directory !== 'webp') {
            return $path;
        }
        return 'app/uploads-webpc';
    }, 10, 2);
    
    add_filter('webpc_uploads_prefix', function ($prefix) {
        return '/';
    });

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    Hello @jcedwards76,

    Thanks for your message.

    The strange thing is there is another uploads folder *within* uploads-webpc containing the actual webp files.

    It is not strange. This is how the plugin works. It does redirects, e.g. from /wp-content/uploads/../*.png to /wp-content/uploads-webpc/uploads/../*.png.webp.

    If you keep everything on a CDN, it is not possible for the plugin to function properly, because it bypasses the redirection from the .htaccess file. This is all explained in more detail in the plugin FAQ.

    Best,
    Mateusz

    Thread Starter Jayme Edwards

    (@jcedwards76)

    If you keep everything on a CDN, it is not possible for the plugin to function properly, because it bypasses the redirection from the .htaccess file.

    Ah. That’s disappointing. Well thanks for clearing it up for me anyway.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Only serving WebP when S3 CDN in W3 Total Cache is Disabled’ is closed to new replies.