# Stop Browsers Prefetching DNS for Links on Your Pages

> Sends the X-DNS-Prefetch-Control header to tell browsers not to look up the domains of every link on your pages in advance, so visitors' DNS providers do not learn which sites you link to before they click.

- Type: PHP
- Runs: Frontend only
- Category: [Privacy & Cookies](https://wpide.com/library/category/privacy/)
- Tags: headers, dns, privacy
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/privacy-dns-prefetch-off/

## Code

```php
add_action( 'send_headers', function () {
    if ( ! headers_sent() ) {
        header( 'X-DNS-Prefetch-Control: off' );
    }
} );
```

## Notes

Explicit dns-prefetch and preconnect hints in your pages still work.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Stop Browsers Prefetching DNS for Links on Your Pages" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
