Skip to content

OpenCart Caching Strategies and Using a CDN

April 11, 2026 3 min read
OpenCart Caching Strategies and Using a CDN - Featured image for this article

OpenCart Caching Strategies and Using a CDN

A fast store is built in layers. No single setting solves everything, but combining several caching layers can take an OpenCart page from 3 seconds down to under 1 second. Let us walk through each layer, from the server to the shopper browser.

Layer 1: OpenCart built-in cache

OpenCart has a built-in caching mechanism in the admin panel (System > Maintenance, or Dashboard settings). It caches catalog data, theme compilation and more. Always enable it in production and clear the cache after changing prices or products.

Layer 2: PHP OPcache

OPcache is a PHP extension that keeps compiled PHP code in memory, avoiding recompilation on every request. This is usually the fastest and free improvement: simply enable opcache.enable=1 in php.ini and allocate enough memory (128-256MB).

Quick OPcache setup

  • opcache.enable=1
  • opcache.memory_consumption=128
  • opcache.max_accelerated_files=10000
  • opcache.validate_timestamps=1 (can be 0 in production)

Layer 3: object cache (Redis/Memcached)

Instead of file-based cache, OpenCart can use Redis or Memcached to keep repeated database queries in memory. This is especially useful for large catalogs and high traffic, as it noticeably reduces MySQL load.

Layer 4: full-page caching

The most powerful layer is full-page caching: storing static HTML so a returning visitor is served the page without invoking PHP and MySQL. It is done with extensions or a reverse proxy (Varnish, Nginx FastCGI cache). Warning: full-page cache must correctly exclude dynamic pages, the cart, checkout, account page, otherwise one user cart could appear to another.

Always exclude from cache

  • Cart and checkout
  • User account pages
  • Login/registration forms
  • Session-based search results

Layer 5: web-server tuning

On Apache (mod_deflate) or Nginx, enable gzip or, better, brotli compression for text files (HTML, CSS, JS), which can cut their size by 70-80%. Also set long-lived Cache-Control headers for static assets (images, CSS, JS) so the browser caches them.

Layer 6: CDN

A CDN (Content Delivery Network) serves static files from the server closest to the shopper. Even Cloudflare free plan gives a tangible benefit: caching, brotli, HTTP/3 and DDoS protection. For Armenia a CDN matters doubly: it speeds the site not only locally but for the large Armenian diaspora in the US, Russia and Europe, where the physical distance to the server is great.

CDN advantages

  • Static files closer to the shopper
  • Brotli and HTTP/3
  • Fast loading for the diaspora
  • DDoS and bot protection

Cache invalidation pitfalls

The hardest part of caching is not enabling it but clearing it at the right time. If you change a price but the cache is not cleared, the shopper sees the old price. Configure automatic cache clearing on product/price updates, and in the CDN use a cache purge after each deploy.

Conclusion: OpenCart speed is the result of a layered approach: built-in cache, OPcache, object cache, full-page cache, server compression and a CDN. Start with OPcache and gzip/brotli (a quick win), then add a CDN and full-page cache, carefully configuring invalidation so shoppers always see current data.

Share: Telegram Facebook X

Stay Updated with OpenCart Armenia

Get the latest OpenCart extensions, themes, and development tips delivered to your inbox.

Join 2,500+ developers and store owners. No spam, unsubscribe anytime