• Hi,

    we have converted all our images to webp using your service and uploaded them to the CDN.

    So we have now 2 files for each images hosted at your CDN.
    As an example:

    https://cdn1.hundemarmelade.de/wp-content/uploads/2022/04/Stevi-und-Schnuecks_Header_Start.jpg => .jpg image
    https://cdn1.hundemarmelade.de/wp-content/uploads/2022/04/Stevi-und-Schnuecks_Header_Start.webp => .webp image

    Your plugin does a rewrite by using a NGINX rewrite rule which delivers the webp image instead of the requested jpg file in case the browser of the visitor supports webp.

        location ~* ^(?<path>.+)\.(jpe?g|png|gif)$ {
            if ( $http_accept !~* "webp|\*/\*" ) {
                break;
            }
    
            expires 31536000s;
            etag on;
            if_modified_since exact;
            add_header Pragma "public";
            add_header Cache-Control "public";
            add_header X-Powered-By "W3 Total Cache/2.2.1";
            add_header Referrer-Policy "no-referrer-when-downgrade";
            add_header Vary Accept;
            try_files ${path}.webp $uri =404;

    }`

    Since we are loading the images from our CDN the HTTP Requests are not hitting our webserver at all and thus the NGINX rewrite rule will not work.
    If we switch of CDN feature everything works as it should.

    So how can i make that work together with the CDN usage of your tool? It must somehow be handled in the browser / markup or by javascript?

    Thank you a lot for your awesome support.

    Best
    Frank

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @technichdml

    Thank you for reaching out and I am happy to assist you with this.
    Once the images are converted, the cache on the AWS needs to be invalidated in order for the AWS to serve webp images instead of the jpeg.
    Have you tried invalidating the cache on the Cloudfront?
    Thanks!

    Thread Starter technichdml

    (@technichdml)

    Hi @vmarko

    I hit the button “Save Settings & Purgae Caches” within “admin.php?page=w3tc_cdn” is that what you mean?

    Had no effect.

    I am wondering how AWS CloudFront should know to serve .webp instead of .jpg for example if the HTML markup at my webpage links to *.jpg and thus thats what is requested from CDN by bypassing NGINX rewrite rules.

    Thanks alot
    Best Frank

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @technichdml

    Thank you for your feedback.
    AWS should respect the mime types set by W3TC as it should respect all existing headers from the origin.
    I’ll have to make some tests with a similar setup where images are already uploaded and then converted.
    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘.webp with CDN’ is closed to new replies.