The most basic way to optimize an ExpressionEngine website is by using best practices when coding the templates. If you’ve been following along up to this point, then you know what those best practices are because you’ve been using them. But sometimes just following good coding practices isn’t enough to guarantee that your site will perform when under medium to heavy traffic. While designing/developing a website with ExpressionEngine, it’s an important concern to have an optimized website to reduce the page load time.
Before we get started, we need to make sure ExpressionEngine is able to create and save the cache files. All cache files created by ExpressionEngine live in the cache directory, which is located in your system directory.

Optimizing with Four Types of Caching

Optimizing your ExpressionEngine website using caching will improve site performance and decrease the load on your server so that your site will load quickly for your visitors. We’ve all visited sites that are painfully slow, but with some caching and optimization we can avoid that.

1) SQL query caching

Most of your database query results are saved in a text file and used the next time the server needs to retrieve the same data.

2) Dynamic channel query caching

This picks up where query caching leaves off, by caching queries that change on every page load.

3) Template caching

This allows you to cache individual templates by saving an almost-static version of that template.

4) Tag caching

This gives you finer control over what in your template gets cached and what doesn’t. This type of caching is not compatible with template caching

Quotes: Template Caching Trumps Tag Caching

In the game of caching, template caching will always override any tag caching set in the same template. So, if you set ExpressionEngine to cache your index template and enable tag caching on one or more tags, the entire template will be cached, and the individual tag cache parameters will be ignored.

Disabling Unneeded Queries

We can improve performance by disabling the channel tag. In general, the disable parameter tells ExpressionEngine to not bother querying the database for specific data. This is a very precise optimization method and one that you should get into the habit of implementing as you build your website.

You can disable five different types of data from within the Channel Entries tag:

– categories
– category_fields
– custom_fields (disables all custom field data)
– member_data (disables all member data, like entry author name)
– pagination

  • If you are using a JQuery module for writing SQL queries, our advice is that you write well-optimized queries to fetch only necessary records.
  • Do not use Embeds unnecessarily since it takes more time while compiling or processing. If the codes are common and used everywhere use snippets or Global variables.
  • If any template is populating so much data/dynamic contents, use Template Caching (It can be enabled from Preferences -> Enable caching by having Refresh Interval).

    You can use the following add-ons for caching:
    1)  CE Cache
    2) Smart Compress
    3) Minimee

  • Avoid using so many if and if: else conditions into a template. Instead of it, the switch can be used with the help of the Switchee plugin.
  • There is also a tracking feature in ExpressionEngine and a few trackings can be disabled if not necessary. Tracking can be disabled
    from Control Panel -> Admin -> Security and Privacy -> Tracking Preferences.
  • Enable GZIP: GZIP can be enabled from Control Panel -> Admin -> System Administration -> Output and Debugging.
  • Avoid using excessive PHP code into a template. Instead of using PHP code into a template, you should develop a plugin to populate the data.

Wrapping Up

Optimization of a ExpressionEngine CMS is as important as a scheduled cleaning of your cupboard. If you leave it cluttered up too long, you may end up with a big pile of mess. As a developer, there are several things that go on parallelly – optimization of the technology that you work with must be in the first few in the list of things.