Good morning everyone,

no question with a direct answer here but looking for what you believe to be the best mix of real time vs caching. A few scenario’s that i would like to have your vision, just to see how different people approach problems from different sides and learn from each other.

A basic website without login dynamic content items. Beside the homepage there are 4 or 5 separate templates. Editors will make a few changes a week but they do receive about 4000 visitors a day on the site.

A site with about 100 products online separated into a few item categories. Beside the homepage, product overview, product detail page there are about 6 to 8 other templates, not coating the ones needed for cart view and checkout process.

The product overview pages don’t show stock information and have no ability for sorting or filtering to decrease server load. In the header the client has an indictor to see if he’s logged in and how many items are in his cart. This information is dynamic for each visitor.

Same setup as the basic e-commerce system but with the added complexity of filtering on the product overview page. Filters generate addition urls. This means that 3 main product overview pages can easily create 1500 separate URL’s with combinations of all the filters.

Knowing ExpressionEngine and the native caching abilities, wanting to use a DRY approach while developing your templates and having the freedom to use add-on like stash and ce_cache. How would you approach these project in terms of template setup, technology choices and caching?

I’ll make a post below describing my setup, choices, pro’s and con’s.

Greets, Bas van Ginkel

1 Answer 1


My own approach varies depending on project and the state of technology. After the introduction of layouts in ExpressionEngine I noticed i really liked using that since it made my template structure clearer and more readable. It also enabled me to work as DRY as possible.

My basic setup always includes structure since that enables me to offer my clients an interface they can easily understand. The core of all my templates always reside in a _structure.group folder. For structure entries I refer to the templates in that group directly. For things like the homepage or other static items that live outside my structure structure I create a homepage.group and from the index.html in that group I embed the correct file stored in the _structure.group.

Recently, and that inspired me to write this post, i’ve been feeling myself getting pushed into a corner when using the layouts method and having the need for caching. I like fine grained control, a want a cache to live forever until I tell the system to break it.

So what i’ll almost always do is to use ce_cache to cache the largest part of the page as possible and include tags referring to the entry_id of all the items included on that page. So for example a blog post page with in the side column a list of other blog entries. What i’ll do is to use ce_cache and tag the main entry with it’s entry_id and also the entry_ids of the items in the side column. I’ll also include a tag like blog_side_column in their. Then when someone makes a change to any blog item i’m able, with ce_cache breaking, to only break those pages where that blog item is used.

I’ll probably first use my default method of using the layouts method including ce_cache. Problem with that is the fact that I can’t seem to figure out how to cache the layout:set items and can’t wrap the entire template since the {layout=“xxxx”} needs to be the first one on the page.

Since this is a small installation I would be inclined to move the actual template info a separate file (_embed.group/blog.html) and use the ce_cache tag around an embed function in (_structure.group/blog.html) to enable full page caching. But I don’t believe this is a very acceptable way of doing things. ;)

As using the approach mentioned above would destroy the visitor dynamic information in the header bar I would be inclined to let go of the advantages the layouts method provides. By going back to regular embed’s and snippets I can maintain a reasonably DRY work method while greatly advancing the methods I can use from ce_cache.

Same as above with some additions. Since the product items used on the product overview page will be visible on a lot of pages I will probably try and use ce_cache to cache those bit globally. That way once generated for one page it gets reusable whenever that product is needed again.

The problem with all those filter pages is that caching is only effective if the client doesn’t change to much. When the client add’s a new product it should show up as soon as possible. So either it need be rendered real time of the cache for those pages needs to be broken when that happens.

For a few recent projects I used http://devot-ee.com/add-ons/reefine to enable the filtering on the site. My client tend to have a requirement that a unique url is available for any filter so they can use that in their marketing efforts.

I do confess that this last scenario is the one i’m most intressted in since that’s been causing me the biggest head aches over the last few months, so i’m looking forward on how your approach would be and discussing on why you think this or that.

greets, Bas van Ginkel

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.