Does minify happen on the fly?


Does html minify happen on the Fly. If i use cache everything, does page with html minify get cached or normal page(without minify) get cached and html minify runs on the fly when a user request that webpage?


CSS & JS minification operates on cached CSS and JS files only. Once Cloudflare returns a cache HIT for the file it will be returned to browsers in minified form.


What about html. My origin send html page as non minify. Cloudflare minify them and send it to user.

Now I use cache everything. User will always get minify html page. But on edge server minify page will save or non minify?

Sorry, I had replied based on the title of your post. HTML is a different story. Since the support article linked above doesn’t say it, I’d assume HTML is indeed minified on the fly, while JS and CSS is, if I understood it well, served as unminified for non-cached files. Cloudflare then stores the minified version in the cache. The cached, minified versions of JS and CSS files are then served from the edge to visitors whenever they get a CF-Cache-Status: HIT header.

As for the cache for HTML pages under Cache Everything setting, it would make sense that CF caches the page under whatever status minification had when the cache was created. You can easily test this by visiting a test page that was minified, to make sure it’s placed in cache, then visit it again after you turn minification off for HTML.

So, it does make sense to minify html before it gets to Cloudflare. It might increase a slight performance improvement.

Yes, normally it does make sense to minify HTML before it gets to Cloudflare, and then uncheck the minify HTML checkbox on the Cloudflare Speed tab. Cloudflare minification is known to be conservative, so if you have a tool like a plugin that does it at the source, it would be preferable then to let Cloudflare do it.

1 Like

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