Is there a function to fetch a site without a DNS cache in JavaScript?

Viewed 210

I'm making a "status" page, and I want to be able to test if the DNS works from the client (to determine if the DNS server is down, or if the client cannot successfully get a resolved query). My existing code

    await fetch('http://google.com/', {
        mode: "no-cors",
        cache: 'no-store'
    })

doesn't work. Cache only completely refreshes the data from the query, not the DNS cache. The code only works in/out of Incognito/Private Browsing, but once it resolves the first time in Incognito, it'll keep Google in the DNS cache, even after closing all private tabs. I'm wondering if there's any way (in or outside fetch()) to query a website straight from DNS without the browser/OS cache, or whether my existing code should work but there's a browser bug. (I'm assuming it's a browser bug with Chromium as if the DNS cache isn't shared between normal and private tabs, then it should also be deleted on the closure of a private browsing session.)

0 Answers
Related