Cloudflare Cache not working (getting bypassed)

Hi there,

I’m trying to have my images cached in cloudflare and have my static ressources cached.

I use a caching plugin (FlyingPress) & I had the same issue with WP Rocket:

My website is www DOT lesfousdisent DOT com, www.lesfousdisent.com

The cache works well at plugin level but it’s not working at server level.

I saw in Cloudflare notes that : When setting Cache control to no-cache with Origin Cache-Control on, Cloudflare caches and always revalidates. Which is what I want.

In cloudflare,

  • I’ve set a page rule that lesfousdisent.com/* has origin cache control ON
  • In cache rules, I’ve bypassed cache for checkout.
  • Browser cache TTL is set to Respect existing headers.

Now when I look at some static images at the bottom end of my site, I see that

In response header :
Cache-Control: private, max-age=31536000
private, max-age=31536000 : BYPASS

In Request header,
Cache-Control: No cache

What am I doing wrong & more importantly, how can I fix this ?

Thanks

My issue is when I look at

It looks like all of your images have that Cache-Control header set to private with a one-year expiration. Does that ring a bell? Any idea where you’re setting that header?

I also notice that you’re serving webp and avif images if the browser requests them, but there are no headers indicating that you’re using Cloudflare to do the conversion. Are you using a Wordpress plugin for this? Is it possible that plugin is setting the Cache-Control header on your images because it’s changing the format? (Caching these images without setting the correct Vary header, which you’re not, will cause a problem with a shared cache where a browser could receive the wrong format of image from the cache, so it seems likely that a plugin would restrict the caching to private.)

1 Like

I’m using a separate plugin: Converter for Media to change my jpegs to webp and avif. This plugin does not change the url, just the format. I have a one year subscription for that. That could be it.

I also saw that all css was in the cache (cf status HIT), so it not a misconfiguration from my side…

I’m going to ask the developer. Thanks a lot

1 Like

Yep. See this page:

Yeah I read that :sob:

I don’t really want to pay $20 / month just for that…

Any feedback which is better in terms of loading time between avif(60 ko) using that plug-in but no cloudflare cdn and jpgs (120 ko) without conversion but with cloudflare cdn?

It’s a lot of smaller images, and most of them are below the fold and lazy-loaded, so my bet would be on using the plugin for avif. Not sure though (and I’ve never used that plugin).

1 Like

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