Troubleshooting

Excessive disk usage in the PrestaShop var/cache directory

Reviewed on 2 min read cache espacio prestashop

The var/cache directory in PrestaShop 1.7 and later can hold both dev and prod at the same time, even though only one is the active environment. Before deleting anything, measure var/cache/dev, var/cache/prod and var/logs separately to identify which path is growing.

Debug mode selects the dev environment and shows errors; the performance profiler is controlled separately through _PS_DEBUG_PROFILING_. Not all growth in var/cache/dev comes from SQL queries, nor does it prove that debug mode is the only cause.

On a shop with traffic, dev can grow significantly and debug mode reduces performance. Check in Advanced Parameters > Performance that Debug mode is disabled.

If you cannot log in to the back office, check config/defines.inc.php. The correct constant has underscores at the start and end:

/* Debug only */
if (!defined('_PS_MODE_DEV_')) {
    define('_PS_MODE_DEV_', true);
}

If it is true, change it to false to disable it:

/* Debug only */
if (!defined('_PS_MODE_DEV_')) {
    define('_PS_MODE_DEV_', false);
}

Also check that _PS_DEBUG_PROFILING_ is false. Then first use the back office's Clear cache feature or the console procedure for your version. If you cannot use either, make a verified backup, put the shop into maintenance mode and remove only the content of the identified environment; do not schedule a recurring deletion without measuring which subdirectory grows again.

Check the storefront, the back office, images, orders and logs before reopening. See the official PrestaShop configuration and its recommendations on the profiler.

Check that it stops growing

Note sizes and file counts before clearing and after reproducing several test visits. Some initial growth while templates are regenerated is expected; continuous growth requires identifying the subdirectory and the component causing it.

Turning off debug mode does not automatically delete the previous dev cache. Nor should you delete the whole of var: it contains more data than the cache. If the real problem is in var/logs, review the repeated message and the retention policy instead of emptying var/cache.

You may also find useful

Something wrong or out of date? Tell us and we will review it.