Jump to content

WEBP-first strategy hook not working after size()


Recommended Posts

Posted

Ok so just stumbled into a website using Clouflare and the plain htaccess method doesn't seem to kick in, tried altering the url() method with a hook but stumbled back into the problem problem where it doesn't seem to work after applying size(). Anybody has some info on this?

if($page->template != 'admin') {
    $wire->addHookAfter('Pageimage::url', function($event) {
        static $n = 0;
        $n = ++$n;
        if($n === 1){
            $event->return = $event->object->webp()->url();
        }
        $n--;
    });
}

 

Posted
6 minutes ago, wbmnfktr said:

Does it work when you enable developer mode in Cloudflare? Just to check if it's really a Cloudflare issue.

Unfortunately I don't have access to the cloudflare account :/

Posted

Ok... that's tough than.

I changed one of my sites (behind Cloudflares Free Plan) to strategy 1 as described here: https://processwire.com/blog/posts/webp-images-and-more/#strategy-1-automatically-delivering-webp-for-jpg-png-images

It works, even in image URLs generated with size().

Ryan says this in the article:

Quote

These rewrite rules will need adjustment if you are using $config->pagefileExtendedPaths (though I don’t think many are using that option).

Maybe that's the reason.

Posted
58 minutes ago, wbmnfktr said:

I changed one of my sites (behind Cloudflares Free Plan) to strategy 1 as described here: https://processwire.com/blog/posts/webp-images-and-more/#strategy-1-automatically-delivering-webp-for-jpg-png-images

This is my "go to" approach but susprisingly it didn't work out as expected. It just delivers the normal jpg image it's as if it's not redirecting the webp header or something, that's why I decided to switch to the extension hook but then I stumbled into this. Maybe I should open a github issue?

Posted

I guess it's still too early for an issue response on Github.

Let's compare the things we can compare:

  • ProcessWire 3.0.132
  • PHP 7.2
  • Cloudflare Free Plan (default settings)
  • webP Strategy 1
  • htaccess: non-www Redirect
  • htaccess: https Redirect
  • pagefileExtendedPaths NOT set

2019-09-18-165025_873x400_scrot.png.bb691f80b76994474231cadc7d1b68d6.png

As you don't have access to the Cloudflare settings... is there someone who can look into it? Maybe they use a load balancer, built in whatever. Maybe the site is still cached. Cloudflare CDN is sometimes bit of a PITA. Dev-Mode or DNS-by-pass would be nice to test out. Maybe there are even custom page rules that are image related. There is a lot of stuff someone can do there.

  • 2 weeks later...
Posted

Hu @wbmnfktr!!

Your post just made me realize, I'm using Runcloud so I have nginx in front of Apache, and just tested another site that is not using cloudflare and same issue, webp is not being delivered. So maybe that could be it? Cause i remember the http-to-https redirect had an issue, so i had to use a special one. 

 

Posted

I don't know if this could be the reason. 

I know that there is one project - I maintain - with a Cloudflare -> Nginx -> Apache setup. Maybe I'll find the time to play around with it on the weekend.

For the moment... ¯\_(ツ)_/¯

Posted
3 hours ago, wbmnfktr said:

For the moment... ¯\_(ツ)_/¯

hahaha thanks a lot for you help and patience! I just pinged on an nginx thread to check if anyone's got some more info.

  • Like 2

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...