Hi,
While benchmarking different CDN providers, I’ve noticed that Netlify has a suboptimal use of the Date
header.
Consequences
- Clients (visitors of Netlify’s sites, browsers) miss their local cache
- Thus it increase the requests to Netlify’s edge servers which result in an increase in bandwidth usage, which has a cost
- It also result in a increase in the TTFB, especially for resources like
.js
.css
.jpg
because even when a resource should be fetched from browser’s cache, it result in a network request.
Problem
Netlify set the Date
HTTP header to the date when the CDN server cached the resource, instead of the time the request is server.
Due to that, Browsers are misusing their local cache, which increase TTFB and bandwidth usage.
You can read here the detailed math: Forums | AWS re:Post
Solution
Edge servers must set the Date
Header to the time the request was served.
They can use the last-modified
header to indicate when the file was modified.
It will result in improved local (browsers) cache hit by all visitors, which will reduce bandwidth usage, TTFB and costs.
Examples in the wild
Both Firebase hosting and StackPath are setting the Date
header to the time the request is served, and the last-modified
header to the time the site is deployed.