Installing Memcache(d) in OpenCart will speed up your online store by reducing database load and improving site responsiveness. Below is a convenient step-by-step guide adapted for different OpenCart versions.
Main Features of Memcached in OpenCart
- Support for various OpenCart versions:
- OpenCart 3.0
- OpenCart 2.2–2.3
- OpenCart 2.0–2.1
- OpenCart 1.5
- Configuration settings:
CACHE_HOSTNAME— path to the socket, for example:/home/your_account/.system/memcache/socketCACHE_PORT=0(used when connecting via UNIX socket)CACHE_PREFIXorMEMCACHE_NAMESPACE— unique prefix for cached data
- Involved files:
config.php,admin/config.phpsystem/config/default.phpindex.php(in root and admin folder)system/library/cache.php(in OpenCart 1.5)
Setup by OpenCart Versions
OpenCart 3.0
- Add to the end of
config.phpandadmin/config.phpfiles:define('CACHE_HOSTNAME', '/home/YOUR_ACCOUNT/.system/memcache/socket'); define('CACHE_PORT', '0'); define('CACHE_PREFIX', 'oc_'); - Open
system/config/default.phpand replace:
with:$_['cache_engine'] = 'file';$_['cache_engine'] = 'memcached';
OpenCart 2.2–2.3
- Add to both config files:
define('CACHE_HOSTNAME', 'unix:///home/YOUR_ACCOUNT/.system/memcache/socket'); define('CACHE_PORT', '0'); define('CACHE_PREFIX', 'oc_'); - In
system/config/default.phpreplace:
with:$_['cache_type'] = 'file';$_['cache_type'] = 'mem';
OpenCart 2.0–2.1
- Add to
config.phpandadmin/config.php:define('CACHE_HOSTNAME', 'unix:///home/YOUR_ACCOUNT/.system/memcache/socket'); define('CACHE_PORT', '0'); define('CACHE_PREFIX', 'oc_'); - Open
index.php(both root andadmin) and replace:
with:$cache = new Cache('file');$cache = new Cache('mem');
OpenCart 1.5
- Add to
config.php:define('CACHE_DRIVER', 'memcached'); define('MEMCACHE_HOSTNAME', 'unix:///home/YOUR_ACCOUNT/.system/memcache/socket'); define('MEMCACHE_PORT', '0'); define('MEMCACHE_NAMESPACE', 'opencart_test'); - Replace the entire code in
system/library/cache.phpwith an updated implementation supporting memcached. (You can use your own version or a community solution)
Advantages of Using Memcached
- Performance. Cache works directly from memory, speeding up OpenCart on all levels.
- Reduced server load. Fewer database requests, especially with high traffic.
- Easy setup. No deep technical knowledge needed, just edit configs and a few files.
- Flexibility and scalability. Works reliably on small hosting and large projects alike.
Conclusion
Memcached is a simple and effective way to speed up OpenCart without extra coding. Setup takes minutes, but the effect is immediate: your site becomes noticeably faster and server load drops. This is especially important for SEO, user experience, and increasing sales. Set it up and see how your store starts to fly!
















































Comments