Where BIND9 saves its cache?

Solution 1:

You seem to be asking two different questions.

For the first, the cache is held only in RAM. However you can view it with rndc dumpdb -cache which will be saved (on Debian and Ubuntu) by default to /var/cache/bind/.

For the second, I think that perhaps you don't know what a view is with regard to bind.

A view is an alternate zone presented to a subset of clients. For example, if you have a private and public network you might create a public only view of your zone for external clients while internal clients will have a view for public and private networks. You can only flush a named view that is configured in named.conf (or any included files).

A view is not the same thing as a zone, and you can't individually flush zones.

Solution 2:

For example in named.conf:

options {
    ...
    dump-file       "/usr/local/etc/namedb/working/named_dump.db";
    ...
}

Solution 3:

What I had to do to view the dump.db file in 2018:

sudo rndc reload

Reload the RNDC Cache

dig website.example

Give it data to cache

sudo rndc dumped -cache

Tell it to start listing cached items

cat /var/cache/bind/named_dump.db

View the cached DB - should display a standard response:

ubuntu.com. 143 A 91.189.94.40

Please note that reloading doesn't appear to affect the file after you've started inputting data.

From my experience, the caching server acts just dandy but viewing the caches files will turn up empty even if the server is working in a practical perspective (e.g. dig google.com 100ms, dig google.com 1ms and 3 mins later still 1ms resolve time). Hope this helps, it's not concrete, it works and I'd appreciate corrections on this answer where appropriate.
Note: This applied to my Ubuntu 12.04 machine and 16.04 machine. I will test Ubuntu 18.04 soon.