How to disable Cloudflare Polish for a specific User Agent?

I would like to disable Cloudflare Polish for a specific User-Agent so that it can take original images. Is it at all possible?

I tried using Transform Rules to add a header to the response, but unfortunately it had no effect.

Did you try purge the cache after creating this rule?

1 Like

Yes. But even for newly uploaded images it doesn’t work.

You are adding a HTTP response header from Cloudflare to the user. This will be added after the object is retrieved from the Cloudflare cache.

You can probably get what you want in a few ways.

One solution is to use a URL Rewrite rule to append a special query parameter to the URL (polish-=off or similar), and then on your Origin append the no-transform Cache-Control directive when you see that query parameter. There is no need to use the no-cache, must-revalidate directives.

2 Likes

Thanks for the idea! I added rewrite rule for this User Agent and such code in .htacces:

<If "%{QUERY_STRING} =~ /polish=off/">
    Header set Cache-Control "no-transform"
</If>
2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.