"Fossies" - the Fresh Open Source Software Archive

Member "incubator-pagespeed-mod-1.14.36.1/html/doc/filter-insert-dns-prefetch.html" (28 Feb 2020, 3005 Bytes) of package /linux/www/apache_httpd_modules/incubator-pagespeed-mod-1.14.36.1.tar.gz:


Caution: In this restricted "Fossies" environment the current HTML page may not be correctly presentated and may have some non-functional links. You can here alternatively try to browse the pure source code or just view or download the uninterpreted raw source code. If the rendering is insufficient you may try to find and view the page on the incubator-pagespeed-mod-1.14.36.1.tar.gz project site itself.

Pre-Resolve DNS

Objective

Reduce DNS lookup time by pre-resolving at the browser.

Configuration

The 'Pre-Resolve DNS' filter is enabled by specifying:

Apache:
ModPagespeedEnableFilters insert_dns_prefetch
Nginx:
pagespeed EnableFilters insert_dns_prefetch;

in the configuration file.

Description

DNS resolution time varies from <1ms for locally cached results, to hundreds of milliseconds due to the cascading nature of DNS. This can contribute significantly towards total page load time. This filter reduces DNS lookup time by providing hints to the browser at the beginning of the HTML, which allows the browser to pre-resolve DNS for resources on the page.

Operation

This filter inserts the tag <link rel="dns-prefetch"> (or <link rel="prefetch"> for IE9) in the HEAD section, for all domains present in the HTML document.

Example

The example below shows the HTML before rewriting:

<html>
  <head>
  </head>
  <body>
    <img src="www.domain1.com/image1.jpeg">
    <script src="www.domain2.com/script1.js">
  </body>
</html>

and after rewriting:

<html>
  <head>
    <link rel="dns-prefetch" href="//www.domain1.com">
    <link rel="dns-prefetch" href="//www.domain2.com">
  </head>
  <body>
    <img src="www.domain1.com/image1.jpeg">
    <script src="www.domain2.com/script1.js">
  </body>
</html>

Limitations

This filter will be applied only on Firefox 3.5+, Chrome, Safari 5+ and IE 9+.

Risks

This filter is considered minimal risk.