diff --git a/manifests/dns.pp b/manifests/dns.pp
index 9887d905f931764262e5977a7cb2cbbedbd3db1c..c36d7fdfdaed0e98c30130ec74a242ae21d03c9b 100644
--- a/manifests/dns.pp
+++ b/manifests/dns.pp
@@ -25,7 +25,7 @@ class base::dns(
     $livermore = false
   }
 
-  if !$no_resolv_conf {
+  if (!$no_resolv_conf) {
     base::dns::resolv_conf { $::fqdn_lc:
       ensure    => present,
       dns_cache => $dns_cache,
diff --git a/manifests/dns/cache.pp b/manifests/dns/cache.pp
index 6ff6934e4c4ac15d83cc2b1557830012d7a63640..c891f8ff071b3cb2277f54228d37f1b2504ada04 100644
--- a/manifests/dns/cache.pp
+++ b/manifests/dns/cache.pp
@@ -1,11 +1,60 @@
 # This class adds a reference to a local DNS caching server.
-class base::dns::cache inherits base::dns {
-  include base::dns::cache_packages
+#
+# NOTE: This class only works with Debian.
+#
+# $cache_size_entries: the number of entries to cache.
+#   Default: 10000
 
-  # We need daemontools for wheezy servers.
+class base::dns::cache(
+  $cache_size_entries = 10000
+) inherits base::dns {
+
+  if ($::osfamily != 'Debian') {
+    fail 'base::dns::cache_packages only works with Debian'
+  }
+
+  Base::Dns::Resolv_conf[$::fqdn_lc] { dns_cache => true }
+
+  # We use stanford-dnscache for wheezy and dnsmasq for jessie and later.
   if ($::lsbdistcodename == 'wheezy') {
+    # WHEEZY
+
     include base::daemontools
+
+    # Stanford package for DNS caching.
+    package { 'stanford-dnscache':
+      ensure => present,
+      notify => Exec['chown dnslog:dnslog /var/log/dnscache'],
+    }
+
+    # This is required because ownership is wrong on reinstall of packages
+    # but not on initial install.
+    exec {'chown dnslog:dnslog /var/log/dnscache':
+      command     => 'chown -R dnslog:dnslog /var/log/dnscache',
+      refreshonly => true,
+    }
+  } else {
+    # JESSIE and beyond
+
+    package { 'dnsmasq':
+      ensure => present,
+    }
+
+    # Call the template for /etc/dnsmasq.d/stanford-dnscache.conf. This
+    # template uses the $cache_size_entries class parameter.
+    file {'/etc/dnsmasq.d/stanford-dnscache.conf':
+      content => template('base/dns/etc/dnsmasq.d/stanford-dnscache.conf.erb'),
+      require => Package['dnsmasq'],
+      notify  => Service['dnsmasq'],
+    }
+
+    # Define the service and make sure it runs. Restart the service if
+    # /etc/resolv.conf changes.
+    service { 'dnsmasq':
+      ensure    => 'running',
+      require   => Package['dnsmasq'],
+      subscribe => File['/etc/resolv.conf'],
+    }
   }
 
-  Base::Dns::Resolv_conf[$::fqdn_lc] { dns_cache => true }
 }
diff --git a/manifests/dns/cache_packages.pp b/manifests/dns/cache_packages.pp
index f6e648b31a94e817d8fdc344ee5fefdbab8e6dea..b2c9ef4cea4cf42d2c9dc13001472c524c758130 100644
--- a/manifests/dns/cache_packages.pp
+++ b/manifests/dns/cache_packages.pp
@@ -1,6 +1,13 @@
-# This class only works with Debian.
+# REMOVE THIS FILE
 
-class base::dns::cache_packages {
+# NOTE: This class only works with Debian.
+
+# $cache_size_entries: the number of entries to cache.
+#   Default: 10000
+
+class base::dns::cache_packages(
+  $cache_size_entries = 10000
+){
 
   if ($::osfamily != 'Debian') {
     fail 'base::dns::cache_packages only works with Debian'
@@ -27,8 +34,10 @@ class base::dns::cache_packages {
       ensure => present,
     }
 
+    # Call the template for /etc/dnsmasq.d/stanford-dnscache.conf. This
+    # template uses the $cache_size_entries class parameter.
     file {'/etc/dnsmasq.d/stanford-dnscache.conf':
-      source  => 'puppet:///modules/base/dns/etc/dnsmasq.d/stanford-dnscache.conf',
+      content => template('base/dns/etc/dnsmasq.d/stanford-dnscache.conf')
       require => Package['dnsmasq'],
       notify  => Service['dnsmasq'],
     }
@@ -41,4 +50,4 @@ class base::dns::cache_packages {
       subscribe => File['/etc/resolv.conf'],
     }
   }
-}
+}
diff --git a/files/dns/etc/dnsmasq.d/stanford-dnscache.conf b/templates/dns/etc/dnsmasq.d/stanford-dnscache.conf.erb
similarity index 59%
rename from files/dns/etc/dnsmasq.d/stanford-dnscache.conf
rename to templates/dns/etc/dnsmasq.d/stanford-dnscache.conf.erb
index fd1ef71c770d28213481febb6970f4d3c05d050d..5b4e7bfa8f8e931cd0a90bded2d65eabe6f5da09 100644
--- a/files/dns/etc/dnsmasq.d/stanford-dnscache.conf
+++ b/templates/dns/etc/dnsmasq.d/stanford-dnscache.conf.erb
@@ -4,5 +4,5 @@ listen-address=127.0.0.1
 # really bind only the interfaces it is listening on
 bind-interfaces
 
-# Cache up to 10000 addresses
-cache-size=10000
+# Cache up to <%= @cache_size_entries %> addresses
+cache-size=<%= @cache_size_entries %>