Introduction
When configuring redirects on a website, especially in the following scenarios, issues can arise:
Redirecting from HTTP to HTTPS: Suppose you’ve set up an SSL certificate to upgrade your website from HTTP to HTTPS. If problems occur during this process, rendering the site inaccessible, you might consider reverting to the HTTP version. However, the challenge arises once a permanent 301 redirection is in place. Even if you remove the redirection on the server, browsers retain this information. Consequently, users’ browsers continue to enforce the HTTPS redirection, preventing them from accessing the HTTP version.
Changing the Website Domain: When migrating a website from one domain (such as old-domain.com
) to another (such as new-domain.com
), a permanent 301 redirection is often employed. This informs search engines and browsers that the site has permanently moved to a new domain. However, if complications arise during this process, you may wish to undo the redirection, allowing users to access the old domain again. Unfortunately, due to browser hard caching of 301 redirections, users become permanently redirected to the new domain, unable to revisit the old one.
To avoid such situations, it is advisable to use a temporary 302 redirection initially, ensuring everything functions correctly. Unlike a 301 redirection, a 302 redirection is not permanently cached by browsers. This means that if necessary, you can revert the redirection without users being permanently locked into the new URL. This approach eliminates the need for users to manually clear their browser caches, enhancing the overall user experience.
301 Redirection: Indicates that a resource (page) has permanently moved to a new location. The client/browser should not attempt to request the original location but use the new location from now on.
302 Redirection: Indicates that the resource is temporarily located elsewhere, and the client/browser should continue requesting the original URL.
A 301 redirection is permanent, meaning that even if removed from the server, browsers will perpetually redirect resources to the new domain or HTTPS due to hard caching.
On the other hand, a 302 redirection is not hard-cached by browsers. If you remove the redirection from your server (website), you can still access the old version.
Clearing 301/302 redirection cache typically involves clearing browser cache or the operating system’s DNS cache. Here’s how to do it on different platforms:
Clearing Browser Cache (Applicable to Windows, macOS, Linux)
Google Chrome:
- Open the Chrome browser.
- Click the three vertical dots in the upper right corner and select “More tools.”
- Choose “Clear browsing data.”
- In the popup window, select the “Advanced” tab.
- Set the time range to “All time.”
- Check the “Cached images and files” option.
- Click the “Clear data” button.
Mozilla Firefox:
- Open the Firefox browser.
- Click the three horizontal lines in the upper right corner and select “Privacy & Security.”
- In the “Cookies and Site Data” section, click “Clear Data.”
- Ensure the “Cache” option is checked.
- Click “Clear.”
Microsoft Edge:
- Open the Edge browser.
- Click the three horizontal dots in the upper right corner and select “Settings.”
- Scroll down and click “View advanced settings.”
- In the “Privacy and services” section, click “Clear browsing data.”
- Check the “Cached images and files” option.
- Click the “Clear” button.
Clearing Operating System’s DNS Cache (Applicable to Windows, macOS)
Windows:
- Open Command Prompt (search for “cmd” in the Start menu and open it).
- Enter the following command and press Enter:
ipconfig /flushdns
macOS:
- Open Terminal (find it in Applications > Utilities folder).
- Enter the following command and press Enter:
Then enter your administrator password and press Enter again.sudo dscacheutil -flushcache
Please note that clearing browser cache might lead to loss of login sessions on websites. Ensure you have backed up essential information in case you need to log in again.
Note: This article is a translated version of the original post. For the most accurate and up-to-date information, please refer to the original source.
```