Caching is the act of saving copies of data (known as cache copies) in memory or on disk in order to make access to that data faster. The cached data can then be used to speed up subsequent requests.
For example, consider the scenario where you are trying to find the contact details of an event on Google Maps. If you already know the location, then you can just search for it on Google Maps. However, if you are trying to find the address of the event, then you will have to first zoom in and then zoom out to get the entire map. This will involve multiple requests to Google Maps in order to get the information. However, if you had saved the map on your device, then you could just zoom to that location to get the contact details. This is caching in action.
What are the advantages of caching?
Cache hits are extremely fast, especially if they are coming from a local cache . Caching allows for fast responses. It speeds up the user experience and reduces bandwidth consumption. Tip: Don’t cache too much! Only include the data that you are certain is fresh. Older data can take longer to deliver. It can also affect the loading speed of pages that depend on the older data. Tip: Use robots.txt to control caching. What is robots.txt? Robots.txt files are text files that tell the web crawler about the cache. They allow you to control what the web crawler can and cannot cache. For example, you can tell the web crawler not to cache images that are over X in size or CSS files that are over Y in size.
What are the disadvantages of caching?
A cache is a faster and smaller form of data storage that stores items. The disadvantages of caching are that it does not store the latest changes and there may be a risk of data loss if the data is not backed up.