The DNS (Domain Name System) is an "index" that associates domain names with their corresponding public IPs. When you access a web page with your browser, the operating system and the browser store the information in their DNS cache upon the first access. This is done to load previously visited websites more quickly without having to query the DNS servers for the correct public IP to route the request each time you access them.

Why clear the DNS cache?

Unfortunately, this leads to problems, some related to security; malware can corrupt the DNS cache and redirect requests to malicious sites (phishing). However, in most cases, the DNS cache can become outdated and create browsing issues. In the case of highly dynamic and complex sites such as an ecommerce in PrestaShop, this can cause problems especially for frequent users. It can happen when using a CDN or when changes at the domain level occur, leading to issues with CSS and JavaScript, or even making the website unreachable. These are rare events caused by changes from providers. These events are temporary since, even without any intervention, the DNS cache will be renewed upon expiration. However, if we are the administrators of an ecommerce and need to access it immediately following a DNS change, perhaps due to moving the website to another hosting or in case of an incident to a new server, it will be necessary to manually clear the DNS cache to speed up the process.

IP Failover

A solution to the DNS cache issue is the use of a personal public IP, which can be quickly moved from one server to another in case of an incident. However, this is only possible within the same network infrastructure; it is not possible, as it is with domain names, to migrate an IP from one provider to another.

Use a VPN

A VPN can not only be useful for increasing security, especially when using public internet connections, but also a professional resource for testing and managing your ecommerce. We recommend using Avira's Phantom VPN, which will allow us to simulate visits from abroad to test any geolocated services.

How to clear the DNS Cache on Windows, MAC, Linux, and Chrome?

Flushing the DNS cache is a fairly simple procedure, but each operating system has a different method for doing it. It is also necessary to check whether it is sufficient to clear it from the computer or if it is also necessary to flush it in the browser. This procedure is valid when discussing DNS-level changes, for example, changing the IP of the MX server or A record, but in the case of an actual change of DNS, the provider's cache (internet connection) is also involved; in this case, one must wait for the DNS propagation (24/48h) or change the DNS of their internet connection to those of Google (8.8.8.8 and 8.8.4.4), OpenDNS (208.67.222.222 and 208.67.220.220), or by using a VPN to bypass the DNS cache of our connection, and access our ecommerce almost immediately without further delay.

Clear the DNS cache in Windows 10

To clear the Windows cache, you need to open the command prompt: Start -> Windows System -> Command Prompt

Once the console is open, we enter the command line:

ipconfig /flushdns

The command "ipconfig flushdns" is used in Windows operating systems to clear the DNS resolver cache. This can help resolve issues related to DNS resolution by forcing the system to retrieve fresh DNS information.

In other versions of Windows, the command is always: ipconfig /flushdns, but the way to access the CMD changes. It should be noted that you should not use Windows XP and 7, especially at a professional/business level, not only for GDPR compliance but for your own safety. In Windows 8, you need to open the APP screen and then look for Windows System on the right and select Command Prompt.

How to clear the DNS cache in Google Chrome?

To clear the DNS cache in Chrome, simply enter the following command in the address bar: chrome://net-internals/#dns and then click on Clear host cache

Clear browsing data in Chrome

After clearing the DNS cache, it is advisable to also clear the browsing cache where the downloaded files are stored locally to speed up navigation. To do this in Chrome, there are various methods:

  • Menu (the three dots), select the More Tools option and then Clear Browsing Data. We can also use the shortcut keys Ctrl+Shift+Del on Windows or cmd+shift+backspace on macOS.
  • By installing a Chrome extension: Clear Cache, highly recommended when managing your own e-commerce or website, in order to check the correct loading after new changes. The cache may not only prevent the latest changes from being displayed but also hide problems introduced with them.

Other very useful extensions when managing your own e-commerce in PrestaShop are:

  • EditThisCookie, which allows you to delete cookies in order to view PopUps set to be seen only once or in case of issues with logins and carts during tests with different users.

Note: the browsing cache requires us to design and study changes in a targeted manner, avoiding improvisation and continuing to make structural changes, such as new modules and features or the removal of already activated functions, especially when the modified code is client-side like JS scripts. For example, if we decide not to ask customers to confirm the terms and conditions of purchase anymore, those who have the old setting in their local cache will not be able to complete the order if they do not clear the cache, because the JS called will not be the new one provided by our server, but the old one still stored locally on the customer's computer. When it comes to e-commerce, everything must be planned and considered.

What if the customer has a problem?

What is mentioned in this article may also concern one of your clients; in the case of DNS cache, it is a very rare issue that usually resolves itself without any action (unless it is corrupted by a problem on the user's PC). However, browser cache is often the source of problems. If a client is unable to complete an order, view couriers, or receives errors with payment methods, the first advice to give is to change the browser they are using or clear its cache.

The problem is much more pronounced when the PC is shared without user separation, a common case in domestic use, where everyone logs in with a single user account.

If the client arrives from a link on Facebook opened within the mobile APP, the cache of the app also comes into play.

How to clear the DNS cache in Firefox?

Firefox also has a simple trick to clear the DNS cache, just enter the command in the address bar: about:networking#dns

FireFox will also show us the current DNS cache data and its expiration.

How to clear the DNS cache in macOS?

As with Windows, it is necessary to open the command line interface; in macOS, it is Terminal, but the procedure varies from version to version of the operating system. If you do not know the version of your macOS, click on the "apple" icon in the top left corner, and select "About This Mac." The first version in the list will be your current version of the operating system.

  • macOS Leopard (10.5), type the command in Terminal: sudo lookupd -flushcache
  • macOS Snow Leopard (10.6), open Terminal and enter the command: sudo dscacheutil -flushcache
  • macOS Lion (10.7), Mountain Lion (10.8), Mavericks (10.9), macOS El Capitan (10.11), Sierra (10.12), High Sierra (10.13), Mojave (10.14), and Catalina (10.15) to open the terminal go to Go -> Utilities and enter the command: sudo killall -HUP mDNSResponder. Confirm the operation by entering your Password.
  • macOS Yosemite (10.10) the procedure to open Terminal is always the same, but the command is: sudo discoveryutil udnsflushcaches. Confirm the operation by entering your Password.

How to clear the DNS cache in UBUNTU?

Surely one of the simplest and most versatile Linux distributions for use as a desktop, also great in a Server environment, clearing the cache is a simple operation and very similar to what is done in Windows and macOS. The first command we can use is: sudo service networking restart, which will restart the network interface, not advisable especially if we are on a server, blocking network services.

If we cannot restart the network services, the dns-clean command, which is installed by default starting from version 10.04, comes to our aid. It will therefore be sufficient to use the command: sudo service dns-clean start to clear the DNS cache without stopping the network services.

Author: Loris Modena

SENIOR DEVELOPER

For Ind Loris Modena, owner of Arte e Informatica, started working in the IT sector in 1989 as a system administrator responsible for the maintenance and installation of computer systems. He began programming for the web in 1997, focusing on CGI programming in PERL and later transitioning to programming in PHP and JavaScript. During this time, he became familiar with the Open Source world and the management of Linux servers.

Product added to wishlist