• Resolved estalhun

    (@estalhun)


    Dear @qtwrk,

    Firefox does not send the webp in the request header so, the .htaccess rule is not working with Firefox properly.
    This is the Accept section of a request header of Firefox:

    text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

    This is the Accept section of a request header of Chrome:

    text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7

    .htaccess:

    ### marker WEBP start ###
    RewriteCond %{HTTP_ACCEPT} "image/webp"
    RewriteRule .* - [E=Cache-Control:vary=%{ENV:LSCACHE_VARY_VALUE}+webp]
    RewriteCond %{HTTP_USER_AGENT} iPhone.*Version/(\d{2}).*Safari
    RewriteCond %1 >13
    RewriteRule .* - [E=Cache-Control:vary=%{ENV:LSCACHE_VARY_VALUE}+webp]
    ### marker WEBP end ###

    This is a problem because Firefox supports the webp format since 2019. What solution do you suggest?

    Best regards,
    @estalhun

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support qtwrk

    (@qtwrk)

    unfortunately there is no solution

    the webp header needs to be present in main request, so the PHP can detect the header

    if it doesn’t give that, then we can not do anything

    and a dirty workaround:

    <IfModule LiteSpeed>
    GeoIPEnable On
    RewriteCond %{HTTP_ACCEPT} "image/webp"
    RewriteCond %{REQUEST_FILENAME}.webp -f
    RewriteRule ^(.*).(jpg|jpeg|png|gif) $1.$2.webp [T=image/webp,L]
    </IfModule>

    this will forcefully load webp when request to .jpg/jpeg/png/gif file and if .webp exists , this request is to single image, not pass through the main request, last time I check it does send image/webp header over image requests though.

    Thread Starter estalhun

    (@estalhun)

    Dear @qtwrk,

    What do you think about this rule? It seems to work for me.

    RewriteCond %{HTTP_USER_AGENT} Firefox/([0-9]+)
    RewriteCond %1 >=65
    RewriteRule .* - [E=Cache-Control:vary=%{ENV:LSCACHE_VARY_VALUE}+webp]
    Plugin Support qtwrk

    (@qtwrk)

    thanks for the code

    we will also implement the fix into newer version.

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