Demac Media Demac Media Brand Demac Media Brand



Anatomy of Magento Cache

Timer Icon 4 Mins

Magento Commerce, Magento Tutorials

In the world of highspeed internet, mobile browsing, and tablets, the typical user just isn’t willing to wait more than a few seconds for a page load anymore. In the of days dialup, it would be perfectly normal to navigate to your desired URL, get up, make a cup of tea, and be back in time for the images on the screen to be half loaded, but these days a slow page load will cost you sales.

Caching has become such a necessary part of internet browsing for this reason. While a user’s browser cache will cache a page that has been visited from the browser on their machine, this will not do for first time visits to a website. This is where Magento’s cache comes in handy. As it caches a page, once anyone hits it, making every subsequent loading of that page lightning quick.

The Basics

In order to use anything to its full extent, you need to at least know a little about it, and Magento cache is no different. Starting off with the basics, cache options can be viewed by navigating to System->Cache Management in the backend. You can see the different areas of caching that can be enabled/disabled, such as any configurations, layout.xml, blocks, full page, and api files. Obviously the ideal is to have all of these enabled once the site is live.

Clearing Your Cache

The cache can also be cleared, or flushed, from here. Pressing the button labeled “Flush Magento Cache” will flush any cache files that match a certain set of built in default tags that Magento uses. This is the “safer” way to clear the cache, as it does not clear absolutely everything. If you are using any secondary cache types, then clicking “Flush Cache Storage” will ensure you have cleared you cache, as it clears EVERYTHING. The other two buttons you see on the admin page will clear the javascript and css, and catalog images.

An alternate, and slightly less safe way to clear the cache is by navigating to “websiteroot/var/cache” and manually deleting all of the files. Same goes for “websiteroot/var/full_page__cache” if you have full page cache enabled.

Full Page Cache

Full page cache, available on the Enterprise Edition, speeds your site up 10 fold, but its important to know a little bit about it, just in case you notice any dynamic content being cached. An interesting file to look at is “websiteroot/app/code/core/Enterprise/PageCache/etc/cache.xml“. Here you can see what is being cached by FPC, the block name, the container name, and the session lifetime. If you find it absolutely necessary to edit or remove any of these blocks from the cache, you can do so by creating a module dependent on the PageCache module, and placing any modifications in there.

The placeholder tag tells the FPC that that block is considered dynamic. When a page is loaded, if the block is not yet in cache this ID value in the placeholder tags is searched for in the cache, and if it doesn’t exist, than that block is called and generated, and the ID is added to the cache.

I’ve found in the past that at times, I’ve had to create a small amount of user specific data, such as a message, that can be changed upon the user reloading the page. In order for this to work without disabling cache, I had to use an ajax call to request from the server after the page load.

If you are having problems with Magento cache enabled on your site, try to fix them! Turning off cache is not a good solution and it will definitely cost you sales. Hopefully these tips will help you understand the cache better and will help you debug problems, rather than disabling the cache.

Subscribe to the Blog

Stay updated with 20,000+ eCommerce leaders in our community

Sign Up

Let’s talk about your 10X return

Icon/Social/Phone Contact us for pricing information