Understanding Cache engines

Since Dolphin version 7.0.3, you can increase your site speed by using different cache engines. Before, Dolphin was file based cache only. Also, beginning with Dolphin 7.0.4, two more cache engines are supported: APC and XCache. Another related new addition in Dolphin 7.0.4 is that you can easily check if some cache engine is enabled on your server. To do this go to:

Dolphin Admin Panel -> Tools -> Host Tools -> click "Cache Engines" tab

Different cache types support different cache engines. The cache engine determines where cache data is stored. By default all cache types are file based, but the file-system is not fast enough in some cases, and other cache types offer faster memory based caching.

Please refer to this tutorial for the help regarding all dolphin cache types.

The reason for using one type of cache and not another another is the size of cache and frequency of use. Smaller and more frequent cache is better for storing in memory, like SQL queries cache. Bigger and less frequently used cache is better stored on the disk, like profiles cache, and there isn't even a choice to select another cache engine for Profiles cache because of this.

In the current Dolphin 7.0.3, you can change cache engines for different cache types in:

Dolphin Admin Panel -> Settings -> Advanced Settings -> Other | Template.

In future versions, all cache settings may be moved to a separate category.

File based

This is the default for all cache types, since it is always available on all servers. As you may have already guessed - cache is stored on the disk in this case.

You may think that this is a very slow variant of cache, since it is disk based, but it is not always true, it may be very fast. For example, Linux disk cache uses as much RAM as possible and if you have enough RAM then all your recently read data is already in memory and works fast. Someone may already have noticed that since all RAM is used on the server, this could be worrisome - this page explains the situation in detail, if you want to know how Linux uses your RAM.

Another advantage of file based cache is that all cache files are actually PHP files, and if you have a PHP accelerator installed, all of these files are already compiled and the most recently used of them are already in the memory and work very fast.

As a result, file based cache is not a bad variant at all in many cases:

  • if you have some php accelerator and set enough memory for it
  • if you have a linux system and enough RAM
  • if you manually increase your disk cache in the OS

It is better to have a dedicated or VPS server - at least to benefit from the dedicated memory it offers. Shared hosting has a lot of sites with a lot of files and it cannot store many files in the memory. Dedicated or VPS servers guarantee that you use dedicated memory. The worst variant is a Windows based VPS server in my opinion, since disk usage is shared between many virtual OS'es and there is no good disk cache by default.

Please note - unlike other cache systems, there is no expiration for this type of cache, because disk based cache is very cheap and there is always enough space for it.

Please note - file based cache cannot be cleared from the admin panel in some cases. It can happen if web-users have no right to delete these files. For example if you transferred the site from one hosting to another and the file owner changed, or if you changed the PHP setup and a web-user also changed. Then, read the note below:

Please note - it is better to clear file based cache using both variants - from the admin panel and manually via FTP or SSH, if you did the following:

  • moved the site from one hosting to another
  • upgraded the Dolphin version
  • changed the Dolphin domain or URL
  • modified the site (it is better to turn off caching entirely if you are modifying something - after modifications are completed, you can re-enable caching)

And the last note - all cache files are in these two folders:

  • /cache/ - during cleaning of this folder leave the .htaccess file here. This file restricts this folder from public access
  • /cache_public/ - there is no .htaccess file here by default, since this folder is publicly accessible

Memcached

This is a special memory cached server which does caching only. This is a very good variant when you have a cluster of webservers and you need to have one cache for all of them. It can be installed on a remote server and do caching only. Also, some webhosting companies offer Memcached servers with their webhosting plans.

It can help a lot if you have shared hosting or a Windows based server. If you have shared hosting, ask your hosting support if they offer a Memcached server with your plan. Also, if you have a dedicated or VPS Windows server, you can ask them to install it for you.

Please note - the clear cache function is not supported for this type of cache, but it clears all data after 1 hour by default. If you need to clear the cache now, then you need to switch to another cache type or disable it and after 1 hour switch back. Alternatively, you can restart a Memcached server.

eAccellerator

This is a PHP accelerator. It compiles PHP files and stores the compiled version. Then the compiled version is used. As the result all PHP pages serve much faster and use less CPU resources. You can benefit from it even more, since it provides shared memory cache API and you can use it in Dolphin as cache engine.

Please note - it is not activated if PHP is working in CGI mode.

One more note - the recent version of eAccelerator (0.9.6.1) doesn't support shared memory functions, so it is better to use another cache engine system when eAccelerator is enabled (for example Memcached). It means that eAccelerator is never available as cache engine if you have 0.9.6.1 version, maybe in future versions it will be available back.

APC

This is also a PHP accelerato,r and it works similarly. The advantage of this cache engine is that it can be easily installed using "pecl" binary.

Please note - this cache engine is available beginning with Dolphin 7.0.4

XCache

One more PHP accelerator which works the same way.

Please note - this cache engine is available beginning with Dolphin 7.0.4

Conclusion

There are many cache engines to choose from, so these are some very basic recommendations:

  • Choose Memcached if your hosting provides it with your plan
  • Choose Memcached if you have a cluster of webservers
  • Enable any memory based caching (not file based) if you have a Windows based server, especially Windows based VPS.
  • eAcclerator, APC and XCache are very similar, choose one, if it is already installed, or if you are going to install one of them from scratch choose eAccelerator - (this one is fastest) or APC - (this one is easier to install).
  • It is fine to use eAcclerator, APC or XCache as a PHP accelerator and Memcached as the cache engine.
Last modified 6 years ago Last modified on Sep 5, 2011, 12:34:57 AM

Attachments (2)

Download all attachments as: .zip

 
Fork me on GitHub