PrestaShop Cache For The Best Optimization

In 2012, I started developing Prestashop. I always make sure to do a couple of things related to the cache when releasing any new project or update for it.

If you’re planning on releasing your project publicly, make sure to clear out any caches that may be lingering. It’s also important when installing add-ons or tweaking settings for the store because these actions can upset things in unexpected ways and result in errors being raised during the installation.

In this article, I will explore everything you need to know about caching.

Is It Safe To Remove PrestaShop Cache Folders

If you are running the PrestaShop store for quite a time, you will notice that a few cache and temp folders in your store are taking up a lot of disk space.

You can remove all the files in the mentioned folders except the index.php file. The index file is used for security reasons— it hides the contents of the folders from quick scanning (a common vulnerability technique).

You might ask where those folders are. Well, if you would scan all v1.7 PrestaShop sources for cache folders you would find 54!

Difference Between Browser Cache and Server Cache

There are three types of caching basically:

Cache TypeHow To RemoveIs It Safe To Remove
Browser CacheBy hitting CMD+SHIFT+R or CTRL+SHIFT+RYes
Server CacheBy removing cache and temp foldersYes
PrestaShop CacheUsually stored in MySQL (database)It Depends*

(* see other sections to learn more)

How to Clear Browser Cache When Solving PrestaShop Issues

If you uploaded a new image in the back office and still see the old one in the front end, your browser shows a cached version just to save some internet bandwidth.

It would be best if you made a “hard reset” in a browser. A typical reset is when you just refresh the page and won’t do things. Still, hard reset informs the browser to ignore the local cache just once while reloading a site.

To reset your browser cache in such cases with CMD+SHIFT+R on Mac or CTRL+SHIFT+R on other OS (no matter what browser).

How to Clear Server Cache for PrestaShop When Solving PrestaShop Issues

PrestaShop stores cache for templates (themes), modules, and configurations into cache and temp folders. If you locate such folders in your FTP – feel free to remove almost all files from there.

Do not touch index.php files, as they are there for security reasons – so online scrappers, cannot scan and download all images from your server at once.

How To Reset PrestaShop Cache

PrestaShop stores its and add-on configurations to MySQL database. Therefore, you should never remove data from the MySQL database directly. Instead, use the back office: Advanced Parameters → Performance → big button at the top of the “Clear cache” page for cache removal.

Best PrestaShop cache configuration - see next topic
Best PrestaShop cache configuration

What Is The Best PrestaShop Cache Configuration

When you arrive at the Advanced Parameters → Performance page, you should see multiple options for cache configuration.

If you are running PrestaShop in the development environment (demo, staging), it would be best to disable most checkboxes using caching.

When using PrestaShop in production mode, here is the best cache setup you should follow:

ConfigValue
Template compilation“Recompile templates if the files have been updated”
CacheYes
Caching typeFile System
Clear cache“Clear cache every time something has been modified”
Smart cache for CSSYes
Smart cache for JavaScriptYes
Apache optimizationYes

Conclusion

Never run PrestaShop in production with the cache disabled. It is effortless to kill the entire store by DDOS’ing (refreshing multiple times).

More great tips on customizing stores could be found in the PrestaShop Customizations blog category.