Flush Chrome and Firefox DNS cache from command line?
Chrome/Chromium's DNS cache is all in RAM. It appears that restarting Chrome completely will inevitably clear it.
The Chromium source for host caching doesn't appear to have any committing to the hard drive for persistence. I can only assume the official Google Chrome does the same thing.
The same goes for Firefox. It appears simply restarting Firefox will clear the cache, as the code for the prefetch system doesn't suggest it commits to the hard disk either.
Related videos on Youtube
Comments
-
eimajenthat over 1 year
Occasionally, I need to do a scorched Earth cleansing of my local DNS cachi. The most common scenario for this was that I was using OpenDNS, and when a name would fail to resolve (it was a hostname on my local network, but wasn't running), OpenDNS sends me to their lovely ad page. Then once the DNS issue is fixed, I'm still resolving to OpenDNS. That actually doesn't happen much, anymore, but still, once in a while, I just need a fresh start with my DNS.
Now, if you are likely to be able to answer my question, I'm sure you will know that modern computers hide DNS cache everywhere. Your OS has it, your browser has it, your other browser has it, if you're running DNSMasq (I am), then you have to clear that as well. So I wrote a little shell script to clear most of these caches, but the browser DNS cache still has too be done manually.
On Chrome, I go to chrome://net-internals/#dns, and click "Clear host cache"
On Firefox, I'm sure there is a similar process, I just don't know what it is.
However, I'd really like to clear both of these from the command line, so I can integrate them into my DNS-burninate script. Can this be done, and if so, how?
If Chrome or Firefox offer a command line interface to do this, that would be super cool.
If not, I assume the DNS cache is stored in a file, or set of files (is that true, or are they all stored in RAM?). If we could identify those files and delete them, perhaps that would have the same effect? Would that work, or just break everything? Where are said files?
Any other ideas?
-
Jan Doggen about 10 years+1 for 'cachi' (let's hope no one edit that out)
-
Arjan about 10 years@Jan, I assume "cachi" is just a typo? (If you think it's the plural of "cache": the OP also used "caches". And I never see people using that.)
-
Jan Doggen about 10 yearsI know it's 'caches'; I assumed it was a word play. And the +1 is actually for the question itself.
-
eimajenthat about 10 yearsYes, it was a bit of word play, 'cachi' rhymes with 'cacti'. But yes, I believe 'caches' is correct. Based on Arjan's profile, I'm assuming English is not his first language (not by your writing, it's flawless, and I applaud you). Word play is some of the hardest stuff to pickup on in another language. I probably shouldn't play such games in an international context. Sorry @Arjan!
-
-
Arjan about 10 yearsWhy do you think this clear the browser DNS caches, like explicitly asked for in the question?
-
Jet about 10 yearsOnce it worked fine for me
-
eimajenthat about 10 years@Jet, thanks for taking a stab at this, but that's the piece I can already do (pretty much like that). Arjan is right. I'm looking to flush the browser DNS caches, which are maintained independently of the system's DNS cache.
-
eimajenthat almost 10 yearsThat's a very simple solution. I like it. I'll give it a try, thanks.
-
Reinaldo Gil almost 4 yearsIsn't work. Just going to Inspertor... Network.. Disable cache. Or by config dnsCacheExpiration = 0.