In two minutes
- Redis is an in-memory database that PrestaShop can use as a cache to avoid repeating queries to MySQL.
- PrestaShop doesn’t ship with Redis: you need a third-party module or cache class. Out of the box there are only Memcache, Memcached, APC and Xcache.
- Orders, carts and customers are always stored in MySQL. A non-persistent cache that gets emptied doesn’t lose a single order.
- The real risk isn’t losing data, it’s showing stale data (stock, prices) if the cache isn’t invalidated properly.
- It’s worth it for shops with large catalogues and plenty of traffic, on their own server and after measuring. In a small shop, you often won’t notice.
What Redis is and what it does in a shop
Redis is a data store that works in RAM. Reading from and writing to it is much faster than doing so in a database like MySQL, which has to search, join tables and sometimes read from disk.
In a PrestaShop shop, Redis doesn’t replace MySQL. It acts as a cache: when PrestaShop runs a read query (the products in a category, a product’s features, the configuration), it stores the result in Redis. The next time it needs the same thing, it reads it from Redis and skips the query.
The idea is simple. What makes it work or fail are the details: what gets stored, when it gets deleted and what happens when Redis isn’t there.
How PrestaShop’s cache works
To understand the benefits and the risks, you need to know how PrestaShop does it. We checked it in the core code (the Cache class and the Db database layer):
- It’s configured under Advanced Parameters → Performance. The systems built into the core are Memcache, Memcached, APC and Xcache. Redis is added with a third-party module or class that uses this same mechanism.
- What gets stored is mainly the results of read SQL queries. Each query is identified by a hash of its SQL text.
- PrestaShop keeps track of which queries depend on each table. When something is written to a table (an
INSERT,UPDATEorDELETEthat goes through theDblayer), all the cached queries that use it are deleted. - There’s a list of excluded tables that never go into the cache: among others, the cart tables (
cart,cart_product,cart_cart_rule), customers and their groups, guests, back-office employees, connections and the log. - A maximum of 10,000 queries are stored per table. When the limit is reached, PrestaShop discards the least used ones.
This design explains almost everything that follows: why orders aren’t at risk, why the cache delivers less than you’d expect in a shop with lots of sales, and where it can fail.
Benefits
- Less load on MySQL. Repeated queries (menus, categories, attributes, configuration) stop reaching the database. At times of heavy traffic, it’s the difference between a calm database and a saturated one.
- Pages that are generated faster, especially category and product pages in large catalogues with many combinations, features and specific prices.
- Faster than the built-in alternatives. File cache uses the disk; APCu lives inside PHP and is emptied every time PHP-FPM restarts. Redis is a separate service, shared by all of the shop’s PHP processes.
- Handles peaks better. Sales, Black Friday, an email campaign: if reads come from memory, the server has more headroom to handle purchases.
- It can be monitored. Redis tells you how many reads find what they’re looking for and how many don’t, how much memory it uses and whether it has had to discard data. That lets you know whether it really helps.
Drawbacks and risks
- One more service to maintain. It has to be installed, secured, its memory monitored and kept up to date. On shared hosting, it often isn’t even possible.
- It depends on a third-party module. Since the core doesn’t include Redis, the module’s quality matters: how it invalidates, what it does if Redis doesn’t respond and whether it’s compatible with your PrestaShop version.
- Stale data if something writes from outside. Invalidation only works when the write goes through PrestaShop’s
Dblayer. If an ERP, an import script or an external process updates stock or prices directly in MySQL, PrestaShop doesn’t notice and may keep showing the cached data. - Invalidation works per whole table. Every time an order is created or stock changes, all the cached queries for the affected tables are deleted. In a shop with lots of sales or constant syncs, the cache is emptied so often that the gain shrinks considerably.
- Problems that are hard to diagnose. “I see one price and the customer sees another” is the typical error of a badly invalidated cache. You need to know where to look.
- Badly sized memory can do more harm than good. If Redis runs out of memory and starts discarding data, it may discard the record that links a table to its queries and leave alive queries that will no longer be deleted when they should be.
Non-persistent cache: what happens if Redis restarts
Redis can work in two ways: periodically saving its contents to disk (persistence, with RDB snapshots or the AOF log) or in memory only. For a cache, the usual recommendation is not to make it persistent.
If Redis restarts (an update, a server reboot, an outage), a non-persistent cache starts empty. What this means in practice:
- No shop data is lost. Everything in Redis is a copy of something that’s already in MySQL.
- For a few minutes, the shop runs as if it had no cache: slower and with more load on the database, until the most visited pages fill it up again.
- If the restart coincides with a traffic peak, this cold start is more noticeable. It’s a reason to schedule restarts at quiet times.
Making it persistent has more drawbacks than benefits: writing to disk uses resources and, when the copy is restored, you may load results that no longer match the database if someone has written to it in the meantime. For a cache, starting empty is the safest option.
What about customer orders?
It’s the key question, and the answer is reassuring: a Redis cache doesn’t put orders at risk, as long as it’s only used as a cache.
- Orders are stored in MySQL, in the order, order line and history tables. Redis is never their source.
- The cart doesn’t depend on Redis either. The customer is identified by an encrypted PrestaShop cookie that contains, among other things, their cart number; the cart’s contents are in the database. On top of that, the cart and customer tables are on the list of tables excluded from the cache.
- If Redis goes down completely, a good module should keep working against MySQL. Test it before going live: stop Redis in the staging environment and place a complete order.
Where you do need to be careful is with the data the checkout reads that isn’t on the exclusion list, above all stock and prices. If they’re updated in a way that doesn’t invalidate the cache, a product page may show an item as available when it has already sold out. In shops synced with an ERP or marketplaces, it’s the first thing to check.
What about sessions?
Redis can also be used to store PHP sessions. Here you need to be careful: if sessions are in a non-persistent instance, a Redis restart deletes them all. In the shop, the cart shouldn’t be lost, because it depends on the cookie and the database; but back-office employees may have to log in again and, if any modules store information in the PHP session, they’ll lose it.
If you want to store sessions in Redis, good practice is to do it in an instance or database separate from the cache, with persistence and without Redis being able to discard them when memory runs short.
How to configure it
A Redis cache configuration for PrestaShop, on your own server, has these key points:
| What | How | Why |
|---|---|---|
| Persistence | save "" and appendonly no | It’s a cache: better to start empty than load stale data. |
| Maximum memory | maxmemory sized for the shop | So it doesn’t eat into MySQL’s or PHP’s memory. |
| Eviction policy | allkeys-lru, with enough headroom that it never has to kick in | If it fills up, discard the least used; and make sure it doesn’t happen. |
| Access | Unix socket or 127.0.0.1, with a password or ACL | Redis must never be reachable from the internet. |
| Separation | One database or instance per shop | So that clearing one shop’s cache doesn’t clear another’s. |
| Flushing | After every update or bulk import | Avoids serving results calculated with older data or code. |
Separation matters when several websites share the same server. When PrestaShop enables or clears the cache, it clears all of it; if several shops share the same Redis database, one can leave the other without a cache.
How to tell whether it’s worth it
Before installing anything, measure. And afterwards, measure again. These are the indicators to look at:
- Server response time (TTFB) of the pages that matter: home page, large categories, product pages and checkout, before and after.
- Slow queries in the MySQL log. If the problem is a badly indexed query, Redis hides it but doesn’t fix it.
- Redis hits and misses (
keyspace_hitsandkeyspace_missesinredis-cli info stats). If most reads find nothing, the cache isn’t doing its job. - Evicted keys (
evicted_keys). If it isn’t zero, memory is short. - Load tests in the staging environment, simulating the traffic of a busy day.
When it’s worth it and when it isn’t
Usually worth it
- Large catalogues, with many combinations, features, specific prices or several languages and shops.
- Shops with plenty of traffic or predictable peaks (campaigns, seasons).
- When the database is already the bottleneck and the queries are well optimised.
- When the shop is on its own server and someone keeps an eye on it.
Often unnoticeable, or not worth it
- Small shops with few products and few visits: MySQL already has everything in memory and the difference is minimal.
- Shops where stock or prices are changed directly in the database from outside and invalidation can’t be guaranteed.
- Shops with syncs so frequent that the cache is constantly being emptied.
- When the speed problem is something else: heavy images, too many modules, a slow theme or an underpowered server.
Redis speeds up what already works well. If a shop is slow because of a bad query or a heavy module, fix that first.
Before Redis, check this
In many slow shops, the first gain doesn’t come from Redis but from more basic things:
- OPcache enabled and properly sized in PHP.
- Smarty cache enabled and CSS and JavaScript files combined, from the same Performance page.
- The database properly configured, with the indexes it needs and without statistics and connection tables growing out of control.
- A review of the modules: which are used, which run queries on every page and which can be removed.
- A modern version of PHP and PrestaShop.
In short
Redis is a good tool for large PrestaShop shops with traffic, on a server that can be configured. As a non-persistent cache, it doesn’t put orders or carts at risk: all of that is in MySQL, and the worst that happens if it restarts is a short spell of slowness. What you need to watch is stale data, above all stock and prices when there are integrations, and available memory.
Is it worth it? It depends on the shop, and the honest way to find out is to measure before and after. If you have a PrestaShop shop and want to know whether it would benefit, see how we build shops, how we configure servers or tell us about your case.


