Netlify ignores cache-control for 304

Edit: Actually, checking the page a few minutes after initial deploy, images are flickering again. For some reason, the headers settings in netlify.toml don’t seem to stick for long.


I can confirm the same issue with our demo site - currently evaluating Netlify / NetlifyCMS for our company site at https://loving-pasteur-90ee68.netlify.com/

304 responses go back to default Cache-Control, leading to noticeable flickering when navigating between pages that use the same image files.

The issue is jarring when using Firefox, less so when using Chrome.

As a workaround, I’ve added the following settings to my netlify.toml - this removes the flickering, with max-age being short enough to invalidate content quickly.

Ideally, we probably wouldn’t have to use this settings, so adding this comment for future reference and to be kept in the loop regarding updates :slight_smile:

[[headers]]
  for = "*.jpg"
  [headers.values]
    Cache-Control = "public, max-age=300"

[[headers]]
  for = "*.png"
  [headers.values]
    Cache-Control = "public, max-age=300"
1 Like