DNSキャッシュのクリアを求められたことがあるだろうか?
このトラブルシューティングのヒントは、特にDNSの変更後にサイトの最新バージョンを取得するのに役立ちます。
DNS情報は、ブラウザーにサイトの場所を知らせます。コンピューターはこの情報をキャッシュに保存し、ブラウザーに正しい方向をすばやく示すことができます。
この投稿では、Mac、Windows、ChromeでDNSキャッシュをクリアする方法をご紹介します。これにより、端末に保存されているDNSレコードを簡単に更新でき、サイトのトラブルシューティングに役立ちます。
このガイドで取り上げる内容を簡単に紹介しよう:
DNSキャッシュとは何か?
DNSキャッシュとは、コンピューターに保存されているアドレス帳のようなものです。アクセスした各サイトのDNS(ドメインネームサーバー)情報が含まれています。
DNSは、コンピューターにドメイン名に関連付けられているIPアドレスを知らせる技術です。さらに詳しく知りたい方は、ドメイン名の仕組みについてのガイドをご覧ください。
DNS情報をローカルDNSキャッシュに保存することで、ブラウザーが素早くサイトを見つけることができる。
ブラウザーにサイトのアドレスを入力すると、まずローカルキャッシュ内のDNS情報を探します。もしDNSが見つかれば、DNSキャッシュを使ってサイトを訪問します。
一方、ローカルDNSキャッシュに情報がない場合、ブラウザーはインターネット上の他のDNSサーバーから情報を取得する。
これにより、ブラウザーは、サイトを訪問するたびに、インターネット上のウェブサイトを特定するために必要なDNS情報を取得するための最短ルートを取るようになります。
しかし、これは時にトラブルを引き起こすこともある。
たとえば、WordPressサイトを新しいドメイン名に移動したり、WordPressを新しいホスティングサービスに移動したりする場合、コンピューター上でDNS情報がすぐに更新されず、古いサイトにアクセスしてしまったり、見つからないエラーが表示されたりすることがあります。
いずれ更新されるだろうが、すぐにDNSキャッシュをクリアできるのに、なぜ待つのか?
さまざまなプラットフォームでDNSキャッシュをクリアする方法を見てみよう。
WindowsでDNSキャッシュをクリアする方法
ここでは、WindowsコンピューターでDNSキャッシュをクリアする方法を説明します。
まず、「スタート」ボタンをクリックし、CMD(コマンドプロンプト)ツールを選択します。
これでコマンドプロンプトウィンドウが起動する。その中に、以下のテキストを入力する必要がある:
ipconfig /flushdns
Enter」キーを押してコマンドを実行すると、WindowsがDNSキャッシュをフラッシュする。
これですべてです。これで、更新されたDNS情報を取得するためのサイト訪問を再開することができます。
macOSでDNSキャッシュをクリアする方法
Macコンピューターをお使いの場合は、以下の手順でDNSキャッシュをクリアできます。
まず、Terminalアプリを起動する必要があります。Launchpadの「Other」フォルダーにあります。また、Finderを開き、アプリケーション ” ユーティリティフォルダーに行っても起動できます。
ターミナル・ウィンドウが起動するので、そこで以下のコマンドを入力する:
sudo killall -HUP mDNSResponder
macOSアカウントのパスワードを入力するよう求められます。これはコンピューターにログインする際に使用するパスワードと同じです。
その後、コンピューターがDNSキャッシュをフラッシュします。これで、サイトにアクセスして最新のDNS情報を取得できるようになります。
ChromeでDNSキャッシュをクリアする方法
Google Chromeは独自のDNSキャッシュも保持しており、オペレーティングシステムが保存するDNSキャッシュとは区切られています。
メインブラウザとしてGoogle Chromeを使用している場合は、ChromeのDNSキャッシュもクリアする必要があります。
まず、ブラウザーのアドレスバーに以下のアドレスを入力し、キーボードの「Enter」キーを押します:
chrome://net-internals/#dns
Chromeのネット内部設定ページが表示されます。
ここから「ホスティングサービスキャッシュをクリア」ボタンをクリックすると、クロームがDNSキャッシュをクリアします。
DNSの更新を確認する方法
WordPressサイトをホスティングサービスに移転する場合、またはドメイン登録を新しいドメイン登録業者に移管する場合、DNS設定を変更し、新しい場所を指定する必要があります。
ドメイン設定にこれらの変更を適用すると、その変更がインターネット全体に反映されるまでしばらく時間がかかります。数時間から数日かかります。
この間、ドメインは古い場所を指すこともあれば、新しい場所を指すこともあります。これは、あなたの地理的な位置と、ブラウザーが指示を求めるDNSサーバーに依存します。
DNSチェッカーのようなオンラインツールを使って、これらのDNSの変更がどのように世界中に伝播しているかを確認することができます。
ドメイン名を入力するだけで、世界中のさまざまな地域からDNSを取得します。
すべての場所で同じIPアドレスが緑色のチェックマークで表示されていれば、あなたが行ったDNSの変更がインターネット上で更新されたことを意味します。
DNSキャッシュとブラウザーキャッシュの違いとは?
ここで、DNSキャッシュはブラウザーキャッシュとは異なることに留意してほしい。
ブラウザーは、繰り返し訪問する際に素早くページを読み込むために、多くのサイトデータを一時キャッシュに保存します。DNSキャッシュにはそれらのサイトが存在するIPアドレスが含まれています。
更新したページが表示されない場合は、ブラウザーキャッシュをクリアしてください。
主要なブラウザーすべてにおいて、ブラウザーのキャッシュをクリアする方法をステップ・バイ・ステップでご紹介しています。
WordPressのキャッシュに関するエキスパートガイド
DNSキャッシュをクリアする方法はお分かりいただけたと思いますが、WordPressのその他のキャッシュに関する投稿もご覧ください。
- 用語集キャッシュ
- 用語集ページキャッシュ
- WordPressのレバレッジ・ブラウザ・キャッシュ警告を簡単に修正する方法
- サイトを高速化するWordPressのベストキャッシュプラグイン
- 初心者のためのW3 Total Cacheインストールと設定方法
- 初心者のためのWP Super Cacheインストールと設定方法
- WordPressのキャッシュをクリアする方法(ステップバイステップ)
- すべての主要ブラウザのキャッシュをクリアする方法(高速な方法)
この投稿が、さまざまな端末でDNSキャッシュを簡単にクリアする方法のお役に立てば幸いです。WordPress のパフォーマンスを高速化する方法、またはサイトを成長させる最高の WordPress プラグインを専門家が選ぶガイドもご覧ください。
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.
Syed Balkhi says
Hey WPBeginner readers,
Did you know you can win exciting prizes by commenting on WPBeginner?
Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
You can get more details about the contest from here.
Start sharing your thoughts below to stand a chance to win!
Jiří Vaněk says
We recently dealt with one of our customers that after changing the DNS records for the domain, he still saw the original website and we saw the new one. We couldn’t figure out what the problem was because we didn’t think it could be this cache (we cleared all other caches before). Only when we cleared the DNS cache using these commands under Windows, the pages were displayed correctly in the browser’s anonymous mode. Subsequently, they also worked in classic mode. So clearing the DNS cache saved us quite a bit of headache and looking for the problem elsewhere.
THANKGOD JONATHAN says
So browser cache and DNS cache are two different things. I was really foolling myself and didn’t think about it. All I does is to clear my browser cache and thought it’s all. Thank you for the article.
WPBeginner Support says
Glad we could clear up the confusion
管理者
Moinuddin Waheed says
I have been in trouble for this mistake many times that is getting confused DNS cache with browser cache and vice versa.
I updated the website and was not seeing the update on my browser.
Then I cleared the browser cache and it worked well.
having said that if we clear the DNS cache with command line , what time it takes to save new domain as cache to load the website faster?
is it recommended to flush the DNS cache regularly?
Jiří Vaněk says
Storing a new domain in the cache is a matter of first loading after clearing the cache. The domain is loaded and the DNS cache saves it. There is nothing more to it. As for some regular cache clearing, it’s not really necessary. Personally, I have never needed to delete the DNS cache, except in cases where, for example, the DNS records on the domain were changed. I also did not know this at first and looked for the error elsewhere. However, in my opinion, you do not need regular deletion, unless you are solving a problem where the DNS cache could play a role.
WPBeginner Support says
It will try to bring in the new content directly and unless there is another caching that causes a problem, you should see the correct site.
You should not need to normally flush your DNS cache.
管理者
Moinuddin Waheed says
Thanks wpbeginner for clearing confusion regarding clearing the DNS cache.
I was confusing it with the browser cache and thought that the new updates will be shown only when we clear the browser cache.
it means we can flush the DNS as and when we think we should.
David says
The articles I have read here in wpbeginner are exceptionally simple (without feeling simplified), clear, informative and most helpful. Thank you!
WPBeginner Support says
You’re welcome! Glad you found our guides helpful!
管理者