Skip to content

← Production for clients

Performance and cache

PrestaShop cache, template compilation and good practices to keep the store fast.

5 slides 5 min read
  1. PrestaShop · Producció

    Performance and cache

    A slow store is a store that loses sales.

    PrestaShop · Production for clients arlaf.dev
  2. PrestaShop's cache

    In production, enable the Smarty cache and disable forced template recompilation. Locally it's the opposite while you develop.

    PrestaShop · Production for clients arlaf.dev
  3. Combine and minify

    The CCC option (Combine, Compress, Cache) merges and compresses CSS and JS. Fewer requests and less weight; enable it in production and verify nothing breaks.

    PrestaShop · Production for clients arlaf.dev
  4. The server side

    What helps most is often outside PrestaShop.

    • PHP OPcache enabled.
    • Data cache with Redis or Memcached.
    • A CDN for images and static assets.
    PrestaShop · Production for clients arlaf.dev
  5. Measure, don't guess

    Before optimizing, measure with a real tool and hit the actual bottleneck. Blind optimization usually wastes time on what doesn't matter.

    PrestaShop · Production for clients arlaf.dev
Read the full note

Un e-commerce lent perd vendes i posicionament. PrestaShop pot anar molt ràpid, però de sèrie ve configurat per desenvolupar, no per produir. Cal canviar el xip en passar a producció.

La cache interna

A producció, des de Paràmetres avançats → Rendiment:

  • Activa la cache de Smarty i posa la recompilació de plantilles en “no recompilar mai”. En local fas just el contrari, perquè vols veure els canvis a l’instant.
  • Activa CCC (Combine, Compress, Cache) per ajuntar i comprimir CSS i JS: menys peticions i menys pes. Després prova la botiga sencera, perquè algun mòdul mal fet pot trencar-se amb el CSS combinat.

El que de veritat mou l’agulla

Bona part del rendiment és fora de PrestaShop, al servidor:

  • OPcache de PHP activat (cache d’opcodes; gratis i molt efectiu).
  • Redis o Memcached per a la cache de dades en botigues amb tràfic.
  • Una CDN per servir imatges i assets estàtics a prop de l’usuari.

La regla d’or: mesura

Abans de tocar res, mesura amb una eina real (el profiler de PrestaShop, eines de rendiment del navegador, etc.) i ataca el coll d’ampolla concret. Optimitzar a cegues és la manera més fàcil de perdre hores en allò que no afectava. Primer la dada, després el canvi.