Database Cache

NitroPack can cache specific database queries in OpenCart known for their slow execution time. In particular, it can cache the product count queries, the category count and product queries, queries for SEO URLs and search queries for specific search terms which you define.

NoteIf page cache or browser cache are enabled, the database cache may be superseded by these other caches. The order in which caches are searched is Browser Cache > Page Cache > Database Cache. So the Database Cache will be searched only if neither Browser Cache nor Page Cache is able to provide a response to the client.

Use database cache when you want to optimize any of these frequent, but expensive database queries. Hard-drive and memory storage options are available.

If the Cache Storage is set to File system (hard-drive) the cache files will be saved in the following directory:

system/nitro/cache/dbcache/

The PHP user must have write permissions for this directory.

The following settings are available:

1. Database cache (Enabled / Disabled) - Used as a general ON/OFF switch for the NitroPack database cache

2. Clear Database Cache - Use this button to clear your NitroPack database cache

3. General > Cache Storage - Use this option to set the desired storage engine for the cache. The available options are:

database_cache_general

- File system (hard-drive) - A file based storage engine that uses files to store cache data. The cache files are saved in system/nitro/cache/dbcache/. Your PHP user must have write permissions to this directory in order to be able to save cache files there.

NoteThe file system storage works on most servers, since it does not need additional software (e.g. Memcache) to be installed on the server. However it has the worst performance, compared to the other storage options, so consider this option only if you cannot use any of the other options. Choose the File system (hard-drive) storage method only if your drive is fast (like SSD), otherwise this may lead to a slower performance on servers with slow hard-drives. If this is the case it is actually better to disable the databse cache.

- Memory (RAM) eAccelerator - A memory (RAM) based storage engine that uses eAccelesator to store cache data. Available only for eAccelerator 0.9.4 and older and is not very well supported. If you want to use this option, but it is grayed out, this means that eAccelerator is not properly installed and you need to contact your hosting provider for further help on installing it.

- Memory (RAM) XCache - A memory (RAM) based storage engine that uses XCache to store cache data. If you want to use this option, but it is grayed out, this means that XCache is not properly installed and you need to contact your hosting provider for further help on installing it.

- Memory (RAM) Memcache - A memory (RAM) based storage engine that uses Memcache to store cache data. If you want to use this option, but it is grayed out, this means that Memcache is not properly installed and you need to contact your hosting provider for further help on installing it. Enabling this option requires you to configure 2 additional parameters - the Memcache server address (default: localhost) and the Memcache port (default: 11211)

- Memory (RAM) Memcached - A memory (RAM) based storage engine that uses Memcached to store cache data. If you want to use this option, but it is grayed out, this means that Memcached is not properly installed and you need to contact your hosting provider for further help on installing it. Enabling this option requires you to configure 2 additional parameters - the Memcached server address (default: localhost) and the Memcached port (default: 11211)

- Memory (RAM) Redis - A memory (RAM) based storage engine that uses Redis to store cache data. If you want to use this option, but it is grayed out, this means that Redis is not properly installed and you need to contact your hosting provider for further help on installing it. Enabling this option requires you to configure 2 additional parameters - the Redis server address (default: localhost) and the Redis port (default: 6379)

NoteAll of the RAM based storage engines offer good performance, so pick whichever one is available on your server. If multiple options are available, pick the one you feel will be the easiest for you to configure. If none of the options are available, you can ask your hosting to install Memcached.

NoteThe difference between Memcache and Memcached is in the adaptors that they use. Memcached is newer and is prefered over Memcache.

Pro TipIf you use Memcache(d) and you have a dev version of your production site and both the production and the dev environments are hosted on the same server, make sure to use a separate Memcache(d) server for the dev environment. Otherwise both OpenCart installations (dev and production) will be sharing the same database cache. This means that the queries that are cached on the dev for example, will be served on the live server, which may lead to unexpected behavior.

4. General > Expire Time (Integer value, representing seconds) - Use this setting to control how long to keep a cache entry. If a database cache entry gets older than this period, it will be automatically re-cached. Default value: 86400 (1 day). We do not recommend values higher than the default.

5. Products > Cache Product Count Queries (Yes / No) - Select whether to cache product count queries. These are queries that count how many products are present in a category.

database_cache_products

6. Categories > Cache Category Queries (Yes / No) - Select whether to cache category queries. These are queries that fetch the list of categories. Many menu modules (including the default one) are doing many category queries each time you visit a page on your site, so it is a good idea to enable this option.

7. Categories > Cache Category Count Queries (Yes / No) - Select whether to cache category count queries. These are queries that count how many categories are present in the store.

database_cache_categories

8. SEO URLs > Cache SEO URLs (Yes / No) - Select whether to cache SEO URL queries. These are queries that fetch the SEO keywords for products, categories and information pages. If SEO URLs are enabled in your store, it is recommended to enable this option.

database_cache_seo

9. Search > Search Keywords Caching (Yes / No) - Select whether to cache queries containing search keywords. These are queries that fetch search results when a customer performs a search in your site. You need to manually list the keywords, that you want to be cached, in the Search Keywords option.

10. Search > Search Keywords - Comma separated list of keywords. The query results for these keywords will be cached. Most effective when used for popular search queries on your site. For example, if you are selling smartphones, you may set this to iphone, apple, samsung because these are popular search terms.

database_cache_search