Simon Sprankel contacted me a few days ago. He is using Lesti_FPC for a customer and he had a block in a few CMS pages. This block has to be dynamic or lazy. I have answered this tricky question a few times via email, but together we have found a good solution that I would like to present in this post.
Lesti_Fpc is internal full page cache for Magento. This Cache needs no varnish or any other extenal software and works with events. It is an internal cache and so it replaces dynamic blocks before sending response to customer. Here is little post that explains the workflow of Lesti_Fpc.
Lesti_Fpc has changed in the last month. Some of the changes are part of the code quality. Today I would like to present the tools, that I use to raise the quality of my Magento extension.
In Lesti_Fpc 1.3.2 I have added the possibility to edit the cacheTags and Parameters via an event. The idea of the Fpc was very clear and simple, but every day I get requests from developers with problems, that aren't that simple. For example oblomovx wanted to Disable Cleaning of Categories after product save. Maybe 98% of all Fpc users didn't need the possibilty to disable this functionality. Or riznmage wanted to Add AJAX parameter to make a differnce between requests that are made by ajax and normal requests. I can understand the need of such a thing, but on the other site I can't implement every crazy idea or I just think that it is wrong to make a ajax request on a action that isn't normally made for it. To let the Fpc simple, but also give those people the possiblity for there workflow I have made it like Magento. I have dispatched some events to work a little bit more advanced with the behavior of the Fpc.
I did start building Lesti_Fpc2. I always wanted a flexible and most compatible solution for Magento. That was never easy. So in Lesti_Fpc I did use the event controller_action_layout_generate_blocks_before as anchor. Just to explain, as anchor I mean the point were the Full Page Cache stops normal behavior of Magento and sends cached response. Normally you want to have this anchor as early as possible. My anchor was very flexible, but also not that fast as I expected.
The Welcome Message in Magento 1.7 is a problem for Lesti_Fpc. You can find the reason in app/design/frontend/base/default/template/page/html/header.phtml.
<!-- ... --> <p class="welcome-msg"><?php echo $this->getWelcome() ?> <?php echo $this->getAdditionalHtml() ?></p> <!-- ... -->
The welcome message is just a function of the header block. Lesti_Fpc needs the welcome message in a seperated block. In Magento 1.8 this is solved and the name of the block is welcome. In Magento 1.7 there is a semi-solution in core, we just have to give a little help.
I have released Lesti_Fpc 1.1.5. What is new in this version? I have add a new field in the configurations. Miss Uri Params, not a really creative and good name. The idea behind this parameters is: No request with these parameters will be cached. For example:
It's getting a little bit complicated. All Miss Uri Param will be seperated by comma and every parameter is sperated with an = from a regular expression. Every request with the parameter limit as an integer will miss the Fpc. I know it makes the configurations complexer, but I guess it will help somebody.
Since version 1.1.1 of Lesti_Fpc I get more support requests for the layered navigation. I did change the behavior of key generating in Lesti_Fpc to get more hits in the cache. I added the new field Uri Params in the configurations and wrote a post about it. This post is all you need to get your layered navigation work, but I guess it would be better to explain it again an example.
I have changed the keys in Lesti_Fpc 1.1.1. There was a problem with parameters in the Cache. Not a real problem, but the cache has produced too much keys. That means, more memory for the cache, but the real problem was, the cache had too much misses.
In Lesti_Fpc 1.1.0 I created a new type of dynamic blocks. I call them lazy blocks. First I will explain what dynamic blocks are and what the difference to lazy blocks is.
Many full page caches are in front of Magento. Often Magento doesn't see the request. That makes external caches very fast. You only have to define a process in front of magento and send your own request. But external caches have to reload dynamic content with ajax and aren't that flexible. Lesti_Fpc has an other workflow.