October 24, 2018

304 Not Modified handling

  Caching, Technical Reference

     

The 304 Not Modified status code is used to indicate that a cached resource has not changed. To make a comparison between the cached and fresh resource, the client sends the value of the Last Modified or Etagheader that was sent when the resource was retrieved. If the the header value matches the value on the fresh resource, then a 304 Not Modified header is sent with an empty body. If the header value is different, the server sends the entire file.

When using a CDN, there are two levels of caches: the browser's cache and the CDN's cache. NuevoCloud treats these two caches separately. It will attempt to confirm the CDN cache with your server, and then it will use it's cache to confirm the browser's cache.

A few example scenarios:

  • If the browser has a file cached, and NuevoCloud's cache is fresh, the resource will be confirmed without contacting your server.
  • If the browser has a file cached, and NuevoCloud does not, the resource will be retrieved from your server, and then used to confirm the freshness of the browser cache.
  • If the browser does not have a file cached, and NuevoCloud's cache freshness needs to be confirmed, it will confirm the freshness of it's cache with your server, and then send the file to the client.
  • If the browser has an older version of a file cached, and NuevoCloud has a different version in it's cache that needs a freshness check, NuevoCloud will confirm the freshness of it's version with your server, and then do a separate check to confirm the browser's cache of that file matches NuevoCloud's cache.