- The Full Page Cache is one of the most important performance features in Magento EE and very few people know how to use it
- Containers control your content
- Processors manage containers
- Knowing containers and processors gets you 90% of the way to solving #1
With my work with ECG one of the more common things I see are performance problems with web sites. Most often it is due to problems that developers have caused with how they interact with database. However, that represents the problems I see. How about the things that people could do better. A big issue that a lot of Enterprise Magento merchants have is that their full page cache is underutilized. You may be saying to yourself “Why don’t I just use Varnish? It’s loads faster anyway.” You can… as part of an overall caching strategy. Varnish is really good for static content. But what happens when someone adds an item to the shopping cart. You are now running fully bootstrapped and laid out Magento requests. That, or you’re now using Ajax and cookies to do things to your layout to make it appear like the shopping cart is being rendered. But it doesn’t just have to be the shopping cart. Anything that needs some level of unique display is a potential cache invalidation feature. What is unique about the Magento Enterprise Full Page Cache is that you get the best of both worlds. You get cached pages AND you get non-static content. Varnish is still going to be faster, but now the difference is 0.5ms vs 20ms instead of 0.5ms vs 2000ms. In many cases, a properly interfaced EE FPC negates the need for Varnish. Following is a diagram that roughly corresponds to how the FPC works and where it hooks in to the process.
There are two places where the FPC hooks into. The first is the request processors. This is at the front of the request. It is done immediately after the app/etc/*.xml files have been loaded. This is because that is where the cache configuration exists. Can use a cache without cache configuration. The FPC is a processor. The processor (Enterprise_PageCache_Model_Processor) is responsible for loading the cache metadata and initial cache content. It then delegates the processing of the cached content to a sub-processor. A sub-processor is in charge of retrieving cached content and merging content into the correct place. There are three types of sub-processors
- Default (typically used by the CMS)
For the most part you do not need to worry about the sub-processors. The real magic occurs in the containers. The containers are responsible for caching and rendering block output. The caching component injects itself into the block output and the rendering injects itself into the sub-processor. Containers are the glue between the cached and uncached content.
A container “injects” itself at certain places in the code and it does this by hooking in to the core_block_abstract_to_html_after event. This happens when the layout is being rendered. If there is a container defined for the block being executed then the FPC will do two things.
- Extract the block’s HTML and save it to the cache
- Surround the HTML with a placeholder tag.
The placeholder tag is used on subsequent requests to find cached output for certain containers when rendering the page from the cache. We’ll take a look at the structure of a full page cached page in a future article. But next up will be the states that the full page cache can be in.