If you have been seeing 404s for /.well-known/traffic-advice
in your access logs from the Chrome Privacy Preserving Prefetch Proxy
bot, you’re not alone. It’s Google Chrome’s private prefetch proxy intended to decrease the Largest Contentful Paint (LCP) performance metric for faster perceived page loads.
There are a few guides (including the first answer on the Stack Overflow question I linked earlier) to have your web server respond correctly to these requests. But I needed a solution where I’m not storing web server configuration along with website content, as my content is populated as a part of a CI pipeline. So I used Nginx’s return directive to hardcode the response body text.
location = /.well-known/traffic-advice {
types { }
default_type "application/trafficadvice+json; charset=utf-8";
return 200 '[{ "user_agent": "prefetch-proxy", "fraction": 1 }]';
}
The location =
matches exactly that path, the types {}
directive empties out the default MIME type definitions and the default_type
directive makes sure the MIME type returned for all requests matching this location is application/trafficadvice+json
, as required. (The charset=utf-8
part is optional, but recommended)
Note that you can use this handy Traffic Advice Checkup Netlify app to make sure your response is well-formed.
Further reading -
- Original proposal
- Blog post with advice for tackling this for other web-servers