Computers and smartphones are a very important part of our daily life as we depend on them to carry out a large part of our daily tasks, whether at work or personal life, and as long as these devices work in the most appropriate manner, therefore, many of us do not care to know how these devices carry out these tasks at such speed, but Knowing these tasks will be useful in all cases, if not out of curiosity, then it must be motivated by knowledge so that you can solve any problem with these devices as long as you know how to work.
But when trying to get to know this matter closely, you may encounter some difficult and incomprehensible technical concepts and therefore we always strive to play our cognitive role and clarify and simplify these concepts in order to be able to absorb them optimally, and in continuation of this matter and within the framework of this series we will highlight today another concept, which is Cache On its types and the role it plays in applications and the operating system.
What is cache?
Let us assume that you are drawing a painting and owns a large group of colors that you will use some of them to draw that painting, thus you will take out the colors that you want to use from the color box one by one whenever you need to use them during drawing, and it will be logical, for example, after using the green color to leave the pen that is Represent it outside the color box so that it is closer to you and you can reach it faster when you want to use it again while drawing instead of putting it in the box and taking it out every time you need it, and likewise you will do the same with the group of colors that you will use in the painting while leaving the rest of the colors that you do not want Use it inside the box as it is so as not to cause you to be crowded and distracted.
This example can be considered as a concept close to cache, when you open an application or a website on your device, whether the phone or the computer, the matter is done as follows, first the program or application files are loaded into the memory or RAM so that they are closer to the processor, thus it can access the program files faster What is the case if the files are on the hard disk, and when applying the example that we mentioned to this case, it is possible to consider the hard disk as the color box and that the data that was saved in RAMs are the most used colors.
In return, the processor will obtain the data that it needs to process from the RAM and save a copy of that data in a memory specific to the processor called cache also, which is a small memory compared to RAM, and therefore the most used data will be stored in that memory to become as close as possible to the processor and is obtained faster while it will be saved The data that is used least in RAM until it is requested from the processor, and in this case the RAM will be the color box, and the data saved in the cache memory of the processor are the most used colors.
After clarification through this example, cache can be defined in general as a process of storing data that was recently used in any process on the operating system so that it can be accessed faster when needed in the near future, and most times that data is stored temporarily thus once the process is completed or re- Operating the operating system, all that data is disposed of until the memory that was stored is freed. Likewise, when the painting is finished, you will return all the colors inside the color box again until you need them again.
Types of cache
The above was an explanation of the concept of cache in general, but when talking in more detail, you will find that cache is used in every operation of the operating system and in every program alone, and the difference is in the quality of the data that is saved, but the purpose is the same in each case, which is faster access to data when needed. To it again, and the most prominent types of cache that we all use on a daily basis are as follows:
1. Cache for programs and applications
As we explained at the beginning of the article, when you run any program on the computer or any application on the phone, the data that it needs on this application or program is saved inside the memory or “RAM” in order to access it faster when the processor needs it, while the less used data is saved on The hard disk or storage memory in the case of smart phones, and that data is disposed of once the program or application process is finished or the device is restarted again, while sometimes the data that is saved on the disk or storage medium may be kept continuously even after restarting the system.
2. Internet browsers cache
Although browsers fall under the classification of programs and applications, their cache is somewhat different. When you visit a site on the Internet through the browser, the browser downloads all site data such as images, “HTML” codes, and the site’s “CSS” formatting codes in addition to the programming codes in a language Java Script for the site on your hard drive and then the site is shown after downloading all those elements and translating them inside the browser to show the page with its natural design.
But the browser, unlike other cases, stores all the browsing cache files on the hard disk permanently and not temporarily so that you can browse the site again faster when visiting in the future, not only that, but because the designs of the websites are sometimes similar, when you visit a site that uses the same format codes or The Java Script codes that were stored within the browser cache files from another previously visited site, therefore, will not be downloaded again, and the site will load faster and without downloading all its data, thus saving Internet consumption.
3. Processor cache
Also, as we mentioned at the beginning of the article, there is inside the processor its own cache memory to store data and commands that have been used or will be used soon so that they can be accessed faster, and because the processor memory is very small, so the processor contains more than one memory called “cache memory levels.” “Each of them is considered a specific level, and the processor often contains either two or three levels of cache, which are numbered from closest to most distant from the processor.
The first memory, or the first level, is the smallest and closest to the processor, and often its size does not exceed 64 kilobytes, and the commands most used or about to be used by the processor are saved inside it, or the second level is often larger in size and is measured in megabytes, as is the case of the third level Which is the most remote from the processor and the largest in size as well.
4. The cache of your hard disk
Some people may not know that the hard disk also has cache files, which are the files that are temporarily stored inside the RAM by reserving a small storage space that is directly proportional to the capacity of the hard disk, and the benefit of cache files in this case is to increase the speed of browsing files and folders on the hard disk By storing the information about the folder and the files it contains inside the RAM, which is what you will feel a lot when opening a folder that contains many files the first time and then closing it and opening it again to find that the files will download faster than the first time.
Should I clear the cache?
In most of the types that we mentioned in the previous paragraphs, you will not be able to control or browse the cache files as the operating system takes over that task automatically in the background, except in only one case, which is the cache of Internet browsers where you can clear the browser’s cache from within the browser settings, which is what It is a very common thing that everyone does when they encounter a problem browsing a site, and you can also control the size of the storage space allocated on the hard disk that the browser uses to store cache files.
Also in the case of smart phone applications on Android phones, you can clear the cache of any application through the system’s settings, and by getting rid of the cache of any application, the application’s data is completely erased and when you start it again it will run without any data as was the case when you first opened the application Once installed, it is also a popular trick for solving app problems.