Use-Cases of this tutorial
- Know how to prevent sending referring url to server when clicking links.
- Know about referrer <meta> tag.
- Know about referrerpolicy attribute of <a> tag.
The referring url may compromise user privacy when a link is clicked. However this can be prevented through the referrer <meta> tag, or using the referrerpolicy attribute on hyperlinks.
The Referer HTTP header tells the visiting website from where the visitor is coming from. This is a part of the request HTTP headers, that can be read by the server.
Why this may be a problem ? This can become a privacy issue as most websites maintain a log of the traffic. Analyzing the traffic may reveal the website a visitor was visiting before clicking on the hyperlink. If the referring url contained a username of some sort, it can be clearly revealed that a specific person with that "username" clicked on the link. With more such similar data, the behaviour and interest of that person can be predicted to an extent.
However there are ways to prevent sending the referrer when a link is clicked. These need a bit of change in the HTML markup.
How to Prevent Sending the Referrer
There are two ways to prevent the sending of referrer when a hyperlink is clicked.
Preventing referrer to be sent for all links in the page
This method involves using the referrer <meta> tag. The effect is site-wide, for all links in the page.
<meta name="referrer" content="no-referrer">
Preventing referrer to be sent for specific links
This method involves using the attribute referrerpolicy in the hyperlink. When set to no-referrer the referrer wont be send.
<a href="https://usefulangle.com" referrerpolicy="no-referrer">Click Here</a>