Skip to main content

A module filter.

Insert DNS prefetch

Resources

Injects <link rel="dns-prefetch"> hints so the browser resolves DNS early.

Filter insert_dns_prefetch · Filter docs · Read the full guide

Original Open in new tab
Optimized Open in new tab

Both frames render identically — that's the goal. The win is in the bytes and requests below, not the look. They're served live by the mod_pagespeed module on demo-httpd-1.1.modpagespeed.com; the optimized frame applies only this filter. Right after a cache purge it may briefly match the original while the worker rewrites it — reload to see the result. mod_pagespeed applies this filter only for browsers it recognizes as supporting it, so the measurement requested the optimized page as a browser.

Measured impact

In this capture the HTML document grows from 281 B to 392 B, so there's no byte or request reduction to chart. The change shows in the source diff below.

What changed in the source

The page's HTML, before and after this filter. Red lines are removed, green lines are added.

                
                  
… 1 unchanged line …
<html>
<head>
<title>insert_dns_prefetch example</title>
- </head>
+ <link rel="preconnect" href="http://www.gstatic.com"><link rel="preconnect" href="https://ajax.googleapis.com"></head>
<body>
<p>
<img src="http://www.gstatic.com/psa/static/1.gif"> <br>

Run this on your own site

This is one of 49 filters the mod_pagespeed module applies in place — self-hosted on Apache, nginx, and IIS. Install and run it: it optimizes right away and adds the optimized response headers shown above. Open source under the Apache License 2.0 — free in development and in production.

Search