Dolphin Caching Types

Dolphin caching becomes complicated, difficult to understand and tune up, so the purpose of this tutorial to shed some light on the subject and make things clear. You will read about all cache types in Dolphin and the benefits you can get from each of them.

Some of these cache types can have different cache engines, so to learn more about cache engines please refer to this tutorial.

This tutorial mostly covers Dolphin caching. For other types of caching and optimization tricks (like MySQL, PHP opcode cache, webserver) please refer to this tutorial.

Many changes in Dolphin caching code were introduced in Dolphin 7.0.3/7.0.4, so all the information is current for Dolphin 7.0.3/7.0.4 and later versions. If you are using earlier versions, most of the information may be irrelevant.

  1. Database cache
  2. HTML files cache
  3. JS/CSS files cache
  4. Profiles cache
  5. Page blocks cache
  6. Member menu cache
  7. Orca Forum cache
  8. Benchmark

1. Database cache

Database cache - stores the most-used and persistent database queries. It may also cache rarely used but slow queries.

To change database cache settings go to:

Dolphin Admin Panel -> Settings -> Advanced Settings -> Other -> Enable DB cache | DB cache engine

There is not much data here, so you can set other memory based cache engines for this type of cache.

Database cache is recompiled in the following cases:

  • When the modules are installed/uninstalled.
  • When files are manually deleted from /cache/ folder (files with "db_" prefix are database cache), when the "File" cache engine is used.
  • When the Apache webserver (or PHP process) is restarted along with using eAccelerator, XCache, APC cache engines.
  • When the Memcached server is restarted along with using the Memcache cache engine.
  • After a 1 hour expiration time, when no "File" cache engine is used.
  • When admin selects "All" or "DB" links in the "Clear Cache" block in the Admin Dashboard.
  • The system automatically recompiles the appropriate part of the database cache when data is changed.
  • When the site URL is changed (however it is recommended to delete cache when you relocate your site).
  • When you upgrade your Dolphin to a newer version (however it is recommended to empty cache manually in this case).

You can check with the Profiler if SQL query is cached: the query is not displayed in the "SQL" Profiler block if it is cached.

Please note - even if you disable this cache, some of the database queries will be still cached, since there are difficult structures that are generated and cached. If it is completely turned off, it will take a considerable time to generate these structures each time.

2. HTML files cache

This is templates cache. Parsing HTML templates takes some time, and the templates cache speeds it up by creating a PHP version of HTML template so it begins to work like regular PHP files, without any parsing, so things are considerably speeded-up.

To change the HTML file cache settings go to:

Dolphin Admin Panel -> Settings -> Advanced Settings -> Template -> Enable cache for HTML files | Template cache engine

It is recommended that you leave the "FileHtml" cache engine here, since there can be a lot of data here. You can set the memory based cache engine, but ensure that you have enough memory there. Also if you install some PHP accelerator along with enabling this cache and using the FileHtml cache engine you can speedup things even more, because the PHP accelerator caches byte code version of PHP files, since HTML cache is based on regular PHP files. The recommended settings here are enabling cache, setting the "FileHtml" cache engine and installing the php accelerator.

HTML files cache is recompiled in the following cases:

  • When files are manually deleted from the /cache/ folder (files with "bx_templ_" prefix are HTML files cache), when "FileHtml" cache engine is used.
  • When the Apache webserver (or php process) is restarted along with using eAccelerator, XCache or APC cache engine.
  • When the Memcached server is restarted, and when the Memcache cache engine is used.
  • After a 1 hour expiration time, when no "File" cache engine is used.
  • When admin selects the "All" or "Templates" links in the "Clear Cache" block in the Admin Dashboard.
  • When the site URL is changed (however it is recommended that you delete cache when the site is relocated).
  • When you upgrade your Dolphin to a newer version (however it is recommended that you empty cache manually in this case).

You can check with the Profiler if the HTML template is cached: "Pages" Profiler block shows the number of cached and not cached templates. Also you can review all entries in the list.

Please note - separate files are created for all combinations of available languages and templates, so if you have several templates and several languages you need more memory for this cache, if memory is used to store the HTML files cache.

3. JS/CSS files cache

Each page has its own combination of JS and CSS files, and it can contain a lot of these files. The client's browser has to download each of these files, causing long page opens and additional server loads. This cache improve this process by combining all CSS and JS files into one file for the particular page. Along with creating one file it can do more optimization steps here. It can compress JS and CSS files to save the bandwidth and improve loading speed even more. Additionally it minifies CSS files (beginning with Dolphin 7.0.4) making it even less in size. All of these things not only speed-up the site, but make for higher rankings in search engines.

To change the JS/CSS file cache settings go to:

Dolphin Admin Panel -> Settings -> Advanced Settings -> Template -> Enable cache for CSS files | Enable cache for JS files | Enable compression for JS/CSS files

There is no cache engines choice here because it some cases cache files are served as static files by the webserver.

JS/CSS files cache is recompiled in the following cases:

  • When files are manually deleted from the /cache_public/ folder.
  • When admin chooses "All" or "JS/CSS" links in the "Clear Cache" block in the Admin Dashboard.
  • When the site URL is changed (however it is recommended to delete cache when your site is relocated).
  • When you upgrade your Dolphin to a newer version (however it is recommended to empty cache manually in this case).

Please note - when compression is enabled it automatically sends expiration headers for 10 days in the future, so files are cached in the client's browser cache for 10 days.

4. Profiles cache

Profiles cache stores each profile information.

To disable/enable this cache go to:

Dolphin Admin Panel -> Settings -> Advanced Settings -> Other -> Enable caching system to store profiles information

There is no cache engine choice here, because it can grow a lot in size with many profiles, and it can be stored on disk only.

Profiles cache is recompiled in the following cases:

  • When the files are manually deleted from the /cache/ folder (files with "user" prefix are profiles cache).
  • When admin chooses the "All" or "Users" links in "Clear Cache" block in the Admin Dashboard.
  • System automatically re-compiles a particular user's cache when this user data is changed.

Please note - when you make any changes with a profile directly in the database you need to clear the profiles cache.

5. Page blocks cache

Any page block in the admin page builder can be cached. It can save a lot of resources since this is high level caching - it caches the ready block with all content.

Be careful with this cache, because many blocks aren't working correctly when cached. Most common blocks which should not be cached:

  • blocks with menus which reloads the block's content
  • blocks which add custom CSS/JS files. In most cases these are blocks which are added to common pages (like the homepage or the profile page) from modules.
  • blocks on dynamic pages, like the profile or dashboard page - these pages are different for each user.

There are a few blocks which are cached by default, but you can cache more blocks for your particular site.

To set cache for particular block, go to:

Dolphin Admin Panel -> Builders -> Pages Blocks -> select page -> click on any active block -> set any number greater than zero in Cache field to cache for N seconds.

To change page blocks cache settings globally, go to:

Dolphin Admin Panel -> Settings -> Advanced Settings -> Other -> Enable page blocks cache | Page blocks cache engine

For maximum performance it is better to use a memory based cache engine.

Page blocks cache is recompiled in the following cases:

  • When the files are manually deleted from the /cache/ folder (files with "pb_" prefix are page blocks cache), or when the "File" cache engine is used.
  • When the Apache webserver (or php process) is restarted along with using eAccelerator, XCache, APC cache engines.
  • When the Memcached server is restarted along with using Memcache cache engine.
  • After the expiration time, a new expiration time is set by user for each block individually.
  • When admin selects the "All" or "Page Blocks" links in the "Clear Cache" block in Admin Dashboard.
  • When the site URL is changed (however it is recommended to delete cache when your site is relocated).
  • When you upgrade your Dolphin to a newer version (however it is recommended to empty cache manually in this case).

You can check with the Profiler to see if page blocks are cached: the "Pages Blocks" Profiler block shows the number of cached and not cached blocks. Also you can review the list.

6. Member menu cache

The Member menu is very complex. It takes considerable time to generate it. After Dolphin 7.0.3 this menu can be cached and it caches the entire menu for each member.

To change the member menu cache settings, go to:

Dolphin Admin Panel -> Settings -> Advanced Settings -> Other -> Member menu cache engine

The default expiration time is 10 minutes for this type of cache, so the actual size of cache depends on the number of logged-in online members. This means that it can be ported to the memory cache engine and it will store data for online members only - your memory will be used economically.

Member menu cache is recompiled in the following cases:

  • When files are manually deleted from the /cache/ folder (files with "mm_sys_menu_member_keys_" prefix are member menu cache), along with using "File" cache engine.
  • When the Apache webserver (or php process) is restarted along with using eAccelerator, XCache or APC cache engine.
  • When the Memcached server is restarted along with using Memcache cache engine.
  • After expiration time, it is set at 10 minutes by default.
  • When the site URL is changed (however it is recommended to delete cache when your site is relocated).
  • When you upgrade your Dolphin to a newer version (however it is recommended to empty cache manually in this case).
  • It is recompiled automatically when relevant data is changed

You can check member menu generation time in "Menus" block of Profile module.

7. Orca Forum cache

The Orca Forum was a standalone product in the past and its structure differs from other Dolphin code. In particular, it has own multilingual system - all PHP/JS/XSL files in the Orca Forum have special markers for language strings. During compilation for a specific language these markers are substituted with real translations. As a result, you have one copy of each PHP/JS/XSL file for every language. The benefit here is that language strings are not substituted in run-time, but a ready version of the script is used for particular language.

This cache need to be compiled for each language and each template, so switch to every one of your template and press "Compile Language" for every language. For Dolphin 7.0.3 and later versions go to:

Dolphin Admin Panel -> Modules -> Orca Forum -> Manage Forum -> Compile Language: XX

For Dolphin 7.0.2 and earlier versions, go to:

Dolphin Admin Panel -> Modules -> Orca Forum -> Compile Language: XX

To clear this cache, delete folders with language name from /modules/boonex/forum/classes/, /modules/boonex/forum/js/, /modules/boonex/forum/layout/ folders.

When no language is compiled then the language markers are displayed, instead of the real language strings. You can work in this mode when changing some files in the Orca Forum and want to see effect without recompiling.

The cache is recompiled manually in most cases, however it can do this automatically:

  • it tries to create this cache for the default template and language during installation
  • it tries to clean this cache for the default template and language during uninstallation

Please note - the language file can not be recompiled if the web-user has no access to recompiled folders. In this case it is better to clear the cache manually (as described above) and set permissions from scratch. Recompilation should work after this.

Also please note - the Orca Forum module uninstall script tries to clear the cache automatically.

8. Benchmark

To show the benefits of Dolphin cache, here is a benchmark test.

Tests were performed in the following environment:

  • Hardware: Intel Pentium E2140 (1M Cache, 1.60 GHz, 800 MHz FSB), 1Gb RAM
  • OS: Gentoo Linux
  • Web-server: Apache 2.2
  • PHP: 5.3.3
  • accelerator: APC
  • Clean Dolphin 7.0.4 development version with default settings with all modules installed

The apache benchmark (ab) tool was used to measure performance:

ab -c 10 -n 100 http://local-domain/local/path/index.php

It means 100 requests with 10 concurrency requests. Total test execution time was measured - so the biggest value means the slowest execution time. The dolphin homepage was tested, since it is the most complex page where all types of caches are used.

The following tests were performed:

  • no acc, no cache: no accelerator is installed and no caching is enabled
  • no acc, file cache: no accelerator is installed and file based caching is enabled everywhere
  • no acc, memcached: no accelerator is installed and the Memcache cache engine is set where possible
  • acc, no cache: accelerator is installed and no caching is enabled
  • acc, file cache: accelerator is installed and file based caching is enabled everywhere
  • acc, memcached: accelerator is installed and the Memcache cache engine is set where possible
  • acc, apc cache: accelerator is installed and the APC cache engine is set where possible, since the APC accelerator is used

Please note - CSS/JS cache and Orca Forum cache settings were not changed since they have no effect in this test.

Also note - Member Menu cache has no effect in these tests since we tested Dolphin as guest.

Common recommendations, according to the graph:

  • it is better to have cache on, since it increases performance in all cases
  • when you have no PHP accelerator installed it is better to enable memory based cache
  • when a PHP accelerator installed, file based cache is the fastest option, but make sure that the PHP accelerator has enough memory to cache all your data
Last modified 7 years ago Last modified on Jan 28, 2011, 9:57:12 AM

Attachments (1)

Download all attachments as: .zip

 
Fork me on GitHub