Disable minification with header

Is there any way to disable the minification for specific responses with an http header from the origin?

Yes, Cache-Control: no-transform

https://support.cloudflare.com/hc/en-us/articles/200168396-What-will-Cloudflare-compress-

Thanks. I already tried this but it stripped away html comments and whitespaces from a markdown file which were important.

Do you think it will help to change the content type header for this file to plain text?

Hi there,

Auto Minify will deliberately skip minification for files that contain .min in their name. You could use this method to disable minification on specific asset(s) if that’s what you’re after.

Alternatively, using a Page Rule set to Disable Performance would disable Auto Minify, along with Polish, Mirage and Rocket Loader on the specified URL pattern.

Would either of these methods work?


https://support.cloudflare.com/hc/en-us/articles/200168196-How-do-I-minify-HTML-CSS-and-JavaScript-to-optimize-my-site-

https://support.cloudflare.com/hc/en-us/articles/200169876-Why-isn-t-Auto-Minify-working-

I tried it with the .min trick, but didn’t work. Had to choose the second method.

Just to clarify, should Cache-Control: no-transform perform this same
function (assuming everything is working)?

it should, yes.

1 Like

Strange, I need to try again…

Be sure to clear the cache (or use development mode) while testing, it could easily be caching a previously retrieved and compressed version of the file. Even if you have a very short cache TTL, if the document itself hasn’t changed (an identical ETag or Last-Modified date) then Cloudflare may decide the cached version is still current, it won’t necessarily consider a Cache-Control header as enough of a change to download a new version of the file.

Development mode will help dodge some of these issues, but be sure to clear the cache when you turn off development mode or it might return the minimized version into service again.

I finally fixed it by using the no-transform header and changing the content type to text/plain. Using .min in the file name didn’t work.

I did a bit of testing here and text/plain shouldn’t be necessary (there are valid reasons to want HTML, jpg or anything else byte-for-byte identical), and it does seem to work for me for these MIME types.

In my case I run some mirrors and one of the requirements is that I serve byte-identical content, no further optimization required, so I add no-transform to the entire site. I never actually looked that closely to see if it worked, but based on reviewing the headers, compression is disabled, and based on hashing the content the bytes of HTML are.

Thats not saying we don’t have different configurations which could be involved as well, there could be other effects from page rules.

Maybe it was also just my fault because either Cloudflare was still serving cached files or my browser mixed something. I’m glad I got it working now.

Exactly! Success is measured in whether it works!

This topic was automatically closed after 14 days. New replies are no longer allowed.