Tag Archivio per: Cache


In the world of computers, machines don’t use names as humans do. They go by a string of numbers. Computers, phones, and all these devices can identify and talk with each other using these numbers, also known as IP addresses. In contrast, humans recognize each other by their names, and it’s difficult for us to remember strings of numbers. Thus, architects have developed a naming system known as Domain Name System or DNS to bridge this communication gap between machines and humans.

The objective of DNS is to resolve names to numbers. To be more specific, it resolves URLs to IP addresses. If someone types google.com in the address bar of their browser window and hits enter, the DNS will resolve this URL to “142.250.179.142” by checking within its database and matching the URL with the IP address. Merienda your machine has this IP address, it can connect with Google and display the website’s contents. To avoid the communication between your computer and the server and minimize the load times, these entries are stored on your computer in a locorregional cache, i.e., DNS cache.

What is a DNS cache

As discussed, it helps your computer network with servers more efficiently. In large setups, resolving domain names to their respective IP addresses can consume a fair amount of time and bandwidth. That’s where a DNS cache comes in handy.

It stores the resolution of your recently queried URLs on your computer, eliminating the need to communicate with the server every time.

You can find the details in our post “What is a DNS Cache?” for a more in-depth explanation of the DNS cache and its purpose.

Why Flush the Cache

Coupled along with the apparent advantages are some disadvantages. For instance, storing a copy of a resolution for later use and the innovador changes will leave you with bad data in your locorregional cache and will not direct you to the intended location. Many malicious actors can also target your locorregional cache to redirect you to harmful web pages.

Therefore, you must frequently flush your DNS cache to avoid such problems. So, how do you flush your DNS cache? If you are running Ubuntu 20.04, you can find a step-by-step guide here.

How To Flush the DNS Cache in Ubuntu 22.04

Now, if you are on Ubuntu 22.04, the “system-resolved” method will not work for you anymore. Let’s check the size of your cache currently. Open up your Ubuntu terminal and run the following:

Now, let’s flush the DNS cache of your Ubuntu system:

Depending on the size of your cache, the process will take some time. As you see, the size of the shown cache wasn’t much. It was completed instantly. Now, let’s check the stats merienda more to ensure this has been completed successfully.

As you see that the Current Cache Size is down to 0, it means that the DNS flush was successful.

Conclusion

In this guide, we learned what a DNS (Domain Name System) is, the benefits of having a locorregional DNS cache, why it’s essential to flush the DNS cache, and how you can manually flush the DNS cache.

We also discussed how you could flush the DNS cache on Ubuntu 20.04 and Ubuntu 20.04, along with how you can view the statistics regarding your cached data.

Fortunately, the process has gotten fairly straightforward in Ubuntu 22.04.



Source link


Pip is the most popular and versatile package installer for Python. It offers a command-line utility that allows you to manage Python packages easily.

Using pip, you can perform actions such as downloading, installing, updating, and uninstalling packages with simple commands.

Pip uses a caching mechanism that allows you to download and install Python packages faster. It works by storing a cache of the downloaded packages on the locorregional wheel.

The caching mechanism allows pip to improve the download and installation of the packages. This is because pip does not need to download already existing packages.

In some cases, pip may not need to redownload a package when updating if it already exists in the cache.

This tutorial will discuss how to work with the pip cache, how to manage the pip cache using various commands, and how to clear it when you need to start afresh.

Pip cache command

In the recent version of pip (i.e., Pip 20.2 and above), you can use the pip cache command to manage the pip cache.

The command syntax:

Let us discuss each action below:

Pip cache dir

This command allows you to get the directory where the pip cache is stored on the target system.

The command:

The command should return the directory where the pip cache is located. Example output on Windows and Linux is as shown below:

pip cache dir
c:usersusernameappdatalocalpipcache

On Linux:

$ pip cache dir
/home/debian/.cache/pip

Pip show cache info

You can use the pip cache info command as shown to get information about the pip cache:

$ pip cache info
Package index page cache location: /home/debian/.cache/pip/http
Package index page cache size: 0 bytes
Number of HTTP files: 0
Wheels location: /home/debian/.cache/pip/wheels
Wheels size: 0 bytes
Number of wheels: 0

The command should return a sample output as:

Pip show filenames and packages in the cache

Pip provides us with the command to view the filenames and directories stored in the cache.

$ pip cache list <pattern>

Pip remove package from cache

To remove a specific package from the cache, you can use the remove action as:

$ pip cache remove <pattern>

The command allows you to specify a specific pattern to match a particular package.

NOTE that the specified pattern can be a glob expression or the name of a target package.

For example, to remove all the files from the cache, you can run:

$ pip cache remove *                                                                                                                                                                                                                                                              
Files removed: 163

NOTE that the command will remove all the files from the cache. Be careful if you do not wish to clear your cache.

Pip clean cache

You may need to reset the pip cache to default in some instances. For that, you can use the purge action as:

Pip Install package without cache

If you want to install a package without looking up the file in the pip cache, we can use the –no-cache-dir.

The command syntax is:

$ pip install package_name –no-cache-dir

For example, to install TensorFlow without looking up the pip cache, run the command:

$ pip install tensorflow –no-cache-dir

The command above should force pip to redownload the package even if it is stored in the cache.

Manually purge pip cache

If you use an older version of pip and have no access to the pip cache command, you can clear the pip cache by manually removing the cache directory.

On Linux:

$ sudo rm ~/.cache/pip
$ sudo rm -rf /root/.cache/pip

On Windows:

rd /s /q «%appdata%localpipcache»

Closing

This tutorial taught you the fundamentals of working with the pip cache. We also covered two methods to clear the pip cache depending on your installed pip version.



Source link