wp-rocket icon indicating copy to clipboard operation
wp-rocket copied to clipboard

Better Optimal Settings in the Cloudflare Addon

Open EusebiuOprinoiu opened this issue 2 years ago • 0 comments

Hello, everyone!

I recently started using the Cloudflare integration provided by WP-Rocket, and I don't think your Optimal Settings are very good.

Issue 1

You're changing the Browser Cache TTL to 1 year. This forces every single cached asset to have this TTL. (including the RSS feeds) The value of Browser Cache TTL is the minimum TTL value for cached assets. Cloudflare checks the original headers and overrides them ONLY if their TTL is lower. If it's higher, it will leave them unchanged.

Because WP-Rocket uses good expiry headers, you should either:

  • leave the Browser Cache TTL unchanged (and respect the user's preference),
  • set the value to Respect Existing Headers (to make sure Cloudflare uses the values set by WP-Rocket), or
  • use a low TTL value (the official Cloudflare plugin uses a value of 4 hours)

If you set a low TTL value (let's say 4 hours), Cloudflare will only change the expiry headers for the RSS feeds from 1 hour to 4 hours. For everything else, it will use the settings defined by WP-Rocket:

  • 4 months for media files
  • 1 year for CSS and JS files

Issue 2

You enable Auto Minify for JS, CSS, and HTML. I think you should only enable minification for JS and CSS and disable it for HTML if it's already enabled. Minifying the HTML has the potential to cause a lot of frustration for people that aren't very good at debugging, and the speed gains are insignificant. (HTML files are usually small, and we also have gzip/brotli compression)

Minifying the HTML removes the comments from the source code, including the WP-Rocket comment that's very useful for debugging the cache. There are also plugins out there that rely on comments for various tasks. (I've encountered some in the past, but their names elude me at the moment)

EusebiuOprinoiu avatar Sep 10 '22 19:09 EusebiuOprinoiu