Plugin to measure DNS latency.
This code is based on Carlos Bueno's guide to DNS on the Facebook Note
For information on how to include this plugin, see the Building tutorial.
Setup
Measuring DNS requires some server-side set up, as documented in detail by Facebook engineer Carlos Bueno, so go read his post for everything you'll need to set this up.
In brief, the points he covers are:
- Set up a wildcard hostname, perferably one that does not share cookies with your main site. Give it a low TTL, say, 60 seconds, so you don't pollute downstream caches.
- Set up a webserver for the wildcard hostname that serves the images named
A.gif
andB.gif
(from theimages/
subdirectory) as fast as possible. Make sure that KeepAlive, Nagle, and any caching headers are turned off. - Include the DNS plugin (see Building)
- Tell the DNS plugin where to get its images from
via
DNS.base_url
Steps 1 and 2 are complicated, and if you don't have full control over your DNS server, then it may be impossible for you to use this plugin.
Beacon Parameters
This plugin adds the following parameters to the beacon:
dns.t
: The worst-case DNS latency from the user's browser to your DNS server.
Methods
-
init(config)
-
Initializes the plugin.
Parameters:
Name Type Description config
object Configuration
Properties
Name Type Description DNS.base_url
string The
base_url
parameter tells the DNS plugin where it can find its DNS testing images. This URL must contain a wildcard character (*
) which will be replaced with a random string.The images will be appended to this string without any other modification.
If you have any pages served over HTTPS, then this URL should be configured to work over HTTPS as well as HTTP.
The protocol part of the URL will be automatically changed to fit the current document.
Returns:
BOOMR.plugins.DNS
The DNS plugin for chainingExample
BOOMR.init({ DNS: { base_url: "http://*.yoursite.com/images/" } });
-
is_complete()
-
Whether or not this plugin is complete
Returns:
Type: boolean
true
if the plugin is complete