Adding `traffic-advice` File to Apache2 Server
On my web server, I was seeing a lot of 404 errors like the one below:
142.250.32.36 - - [22/May/2025:02:47:35 -0400] "GET /.well-known/traffic-advice HTTP/1.1" 404 4259 "-" "Chrome Privacy Preserving Prefetch Proxy"
After some googling, I came up with the following solution.
- Create a JSON file
/var/www/traffic_advice.json
with the following content:
[
{
"user_agent": "prefetch-proxy",
"google_prefetch_proxy_eap": {
"fraction": 0.9
}
},
{
"user_agent": "Chrome Privacy Preserving Prefetch Proxy",
"google_prefetch_proxy_eap": {
"fraction": 0.9
}
},
{
"user_agent": "*",
"accept": {
"purpose": {
"prefetch": true,
"prerender": true
},
"sec-purpose": {
"prefetch": true,
"prerender": true
}
}
}
]
The location is not important; in my case it happened to be root directory for all sites.
- Create the following Apache2 configuration file
etc/apache2/conf-available/traffic-advice.conf
:
# Global traffic-advice configuration
Alias "/.well-known/traffic-advice" "/var/www/traffic-advice.json"
<Files "traffic-advice.json">
# Set the appropriate headers
Header always set Content-Type "application/trafficadvice+json"
Header always set Permissions-Policy "browsing-topics=(), prefetch=()"
</Files>
Make sure the file location on the Alias
line matches the location of the traffic-advice.json
file.
- Enable the Apache2 headers module:
$ sudo a2enmod headers
$ sudo systemctl reload apache2
- Enable the newly created configuration:
sudo a2enconf traffic-advice
sudo systemctl reload apache2
- Use
curl
to verify the server response:
curl -i https://neacsu.net/.well-known/traffic-advice
HTTP/1.1 200 OK
Date: Sun, 01 Jun 2025 16:58:32 GMT
Server: Apache/2.4.41 (Ubuntu)
Content-Type: application/trafficadvice+json
Permissions-Policy: browsing-topics=(), prefetch=()
Last-Modified: Sun, 01 Jun 2025 16:47:43 GMT
ETag: "19c-6368567f7b9ac"
Accept-Ranges: bytes
Content-Length: 412
[
{
"user_agent": "prefetch-proxy",
"google_prefetch_proxy_eap": {
"fraction": 0.9
}
},
{
"user_agent": "Chrome Privacy Preserving Prefetch Proxy",
"google_prefetch_proxy_eap": {
"fraction": 0.9
}
},
{
"user_agent": "*",
"accept": {
"purpose": {
"prefetch": true,
"prerender": true
},
"sec-purpose": {
"prefetch": true,
"prerender": true
}
}
}
]