PrestaShop keeps each visitor’s cart, login, and language in a session cookie (PrestaShop-…). If pages that depend on that session are cached, visitors can get logged out, lose items they added to the cart, or see out-of-date cart contents.
The firewall recognizes the login cookies of several platforms automatically, but not PrestaShop’s, so you need to configure two things.
1. Mark visitor-specific pages as private
The firewall never caches a page your server marks Cache-Control: private, for every Cache Level.
Add this to your .htaccess file to mark pages as private:
# BEGIN Prevent PrestaShop session pages from being cached
<IfModule mod_headers.c>
<FilesMatch "\.php$">
Header set Cache-Control "private, no-store, no-cache, must-revalidate"
</FilesMatch>
</IfModule>
# END Prevent PrestaShop session pages from being cached
Or add this to the top of your index.php, but check with your developer first that it won’t break your store:
// Prevent the firewall and browsers from caching visitor-specific pages.
header('Cache-Control: private, no-store, no-cache, must-revalidate');
Static files (images, CSS, JavaScript) are still cached by the firewall, so your store stays fast.
For NGINX or IIS servers, ask your hosting provider to convert these .htaccess lines to NGINX or IIS rules.
Don’t rely on
Vary:Cookie. Earlier versions of this article recommendedHeader append Vary "Cookie", but that doesn’t stop a page from being cached on the firewall. UseCache-Control: privateinstead, as mentioned above.
2. Recommended: set the Cache Level to “Site Caching”
In the Sucuri Firewall dashboard, go to Performance → Caching Level and select Site Caching.
With Site Caching, the firewall also follows your server’s other cache headers, such as no-store, no-cache and max-age. On Enabled and Minimal, the firewall uses its own fixed cache times. Cache-Control: private still prevents caching on those levels, but the other headers are ignored.
If you can’t change your server
Add the session-dependent pages to Performance → Non-Cache URLs. This works on every caching level.
URLs starting with /cart, /checkout, /orders, /login or /customer are already excluded automatically, but PrestaShop’s default /order, /my-account, /authentication, /identity, /addresses and /order-history pages are not. Add them (and their translated versions, such as /es/carrito, if your store is multilingual).
Check that it works
-
Clear the firewall cache: Performance → Clear Cache.
-
Run this command three times, replacing the URL with a product or category page:
curl -s -o /dev/null -D - https://yourstore.com/your-page | grep -i -E 'x-sucuri-cache|cache-control' -
You should see
cache-control: private, no-store…andx-sucuri-cache: MISSon every run. If aHITis returned, it means the page is still being cached, you should check the firewall Cache Level and ensure the header is set properly.