Browser vs Cloudflare Cache

If in our .htacess file we have .png images set to be cached for 1 month in the browser like this:

ExpiresActive On
ExpiresByType image/png “access plus 1 month”

Let’s say a user visits the page.
The image is cached in the browser.
We upload a new version of the image and go into our Cloudflare account and purge the cache on that particular image file.
What happens when the user goes back to the page?
Does the browser cache override the Cloudflare Cache or vice versa?
Does the user actually need to do a refresh or will simply visiting the page accomplish the new image being displayed?

The browser cache wins. Once your browser grabs a file with a cache set, it will hold that file until the browser cache expires. The user would have to force a refresh…and then it will pull whatever version of the file Cloudflare has in its cache.

Cloudflare’s cache is Cloudflare holding onto that file until its Edge cache expires.

1 Like

Caching rule of thumb:

Acquire resource from the closest source.

In your case browser.