The purpose of setting referrer is to determine whether to carry the original site URL to the external website when jumping to the external domain name. The default browser carries the URL to the external website, so the default external website can be tracked to the incoming website, but it can be turned off through settings (reference source).
Add code
//所有请求不发送 <meta name="referrer" content="no-referrer"> //同源的请求,会发送referrer <meta name="referrer" content="same-origin">
Reference Documents:https://www.w3.org/TR/2017/CR-referrer-policy-20170126/#referrer-policies
enum ReferrerPolicy { "", "no-referrer", "no-referrer-when-downgrade", "same-origin", "origin", "strict-origin", "origin-when-cross-origin", "strict-origin-when-cross-origin", "unsafe-url" };
Empty string
no-referrer
All requests do not send referrerno-referrer-when-downgrade
By default, referrer will not be sent when making a request from https to http.same-origin
For requests from the same origin, a referrer will be sentorigin
Will send, but only send protocol and domain name informationstrict-origin
Yes, but only the protocol and domain name information will be sent. Referrer will not be sent when the request is from https to http.origin-when-cross-origin
For requests from the same source, a referrer will be sent. For requests from different sources, only the protocol and domain name information will be sent.strict-origin-when-cross-origin
For requests from the same source, a referrer will be sent. For requests from https to http, a referrer will not be sent. At other times, only the source information will be sent.unsafe-url
Send referrer at all timesThere are four methods:
Referrer-Policy: origin
<meta>
The element changes the Referrer Policy and directly modifies the content named referrer <meta name="referrer" content="origin">
<a>
, <area>
, <img>
, <iframe>
, or<link>
Set the referrerpolicy attribute on the element <a href="http://example.com" referrerpolicy="origin">
<a>
, <area>
, <link>
Element sets the link relationship of rel <a href="http://example.com" rel="noreferrer">
<meta name="referrer" content="no-referrer">
At this time, statistics such as Baidu Statistics and cnzz will become invalid.<meta name="referrer" content="no-referrer">
, avoiding downstream tracking.