Caching in PrestaShop: Smarty, Symfony, CCC and page cache, what to enable
PrestaShop has several caches that are nothing alike. Understanding what each one stores avoids both slowness and “I can’t see my changes” errors.
When someone says “I’ve cleared the cache and nothing has changed”, they have almost always cleared one of the several caches a PrestaShop store has. These are the layers, from the inside out.
1. OPcache (PHP)
Stores PHP code that has already been compiled. It does not affect data, only speed. Always enabled in production.
2. Symfony cache
In var/cache/prod: the service container, routes, back office Twig templates. It rebuilds itself when cleared. If you install a module and its screen throws an error, clearing this cache is the first step.
3. Smarty cache
Compiles front office templates and, optionally, stores the HTML of some blocks. In Advanced Parameters > Performance:
- Template compilation: “Never recompile template files” in production.
- Cache: enabled.
4. CCC: combine, compress and cache
Merges the theme’s and modules’ CSS and JS into a few files. Fewer requests, faster page. But if a module adds scripts in an unorthodox way, something may break: enable it and check the cart and checkout.
5. Data cache (Redis, Memcached, APCu)
Stores the results of database queries. Useful in large stores, but delicate: if the cache is not invalidated when data changes, you will see stale information. We cover it in detail in the article on Redis.
6. Full-page cache
Stores the whole generated page and serves it without running PrestaShop (LiteSpeed Cache, Varnish, page cache modules). It is the one that speeds things up the most and the one that needs the most care: cart, customer group prices, stock and personalised messages must not come from a page stored for another visitor.
Order for clearing caches
- Page cache (if there is one).
- Data cache.
- Performance > Clear cache (Smarty and Symfony).
- Browser cache (hard reload).