Hi! I’m Marko. Long time no see you, guys. Today, I come back with a tutorial post that, hopefully, it’ll be useful for you.
You must have heard a lot about “cache”, even you are not a developer. However, how much do you understand about it? In this post, I want to share with you my knowledge about cache and Magento cache because we are all interested in Magento 🙂
Read more: Magento 2 news 2016
Cache is a place to store data temporarily in computing environment, which helps increase processing speed of the future request for that data. Data saved in cache are usually pre-computed or the duplicates of original data. If requested data are contained in cache, the request will be served by simply reading cache, instead of taking time to recompute data from database.
With this definition, web cache can be known as users’ web brower data storage. Many people misunderstand web cache as a type of cache, but in fact, it is just an application.
Web cache is placed between Web Servers (or main servers) and client (or many clients). Web cache follows the requests from HTML page, images and folders (a.k.a objects), giving out by making a copy for these objects. Then, if there is a request for the same object, the current copy will be used, rather than requesting from server.
There are 3 types of Web cache, including:
– Browser Cache: Allow users to save browsed data in a specific part of hard driver on the computer. Browser cache works in a simple rule: checking what you have seen are updated or not.
– Proxy cache:
- Web proxy cache works similarly to browser cache, but in larger aspect. Proxy cache serves from hundreds to thousands of users with the same method.
- It is usually installed in firewalls, or as an independent equipment.
– Gateway Cache:
- Gateway Cache plays the mediating role.
- It is deployed by web administrators or web masters to save bandwidth so that the website can be spread, trustworthy and optimized.
In Magento, cache is in var/cache folder. “Flush cache” means to free cache memory. There is a difference between Flush Magento Cache and Flush Cache Storage. Flush Magento Cache will delete cache data saved by Magento (with Magento tag), while the latter will remove all the data in cache.
Magento Cache is stored under key – value form, like other systems. Therefore, if we want to keep any data in cache, we need to mark it with 1 key. The function of “save” and “load” in class is:
Mage_Core_Model_Cache
save($value, $key, $tags = array(), $lifeTime=null)
load($key)
We just need key to request data from cache and have the corresponding one.
For most of people in the first time they work with cache, the block they wrote isn’t displayed or the model doesn’t execute the command to retrieve data. And everything only works out when cache is disabled or flushed. One line in the cache table of System > Cache Management Menu represents for one cache option. There are 8 options in total, saved in core_cache_option table. Moreover, each line represents for one cache tag. When we refresh one of these lines by using mass action, it means that we delete cache with corresponding tags.
If you have any questions related to this topic or want to know more about which topic in Magento, tell me, we will try to help you figure out.
See you in the next tutorial.
P/s: We will update Magento tutorial regularly, especially about Magento 2. Let’s subscribe to our blog to be the first one catch up with the latest news by leaving your email below.
[mc4wp_form]
2 Comments
Hi,
this is a useful tutorial.
I would like to ask you, when you write “Flush Cache Storage will remove all the data in cache” do you mean that it will remove Magento Cache too or all the data in cache except Magento Cache?
Thanks,
W1
Hi there,
Thank you so much for your question. “Flus Cache Storage will remove all the data in cache” means that it will remove all the data including Magento Cache.
If you have any question, please tell us then.
Have a nice day!