PrestaShop Cache For The Best Optimization

PrestaShop Cache For The Best Optimization

I started PrestaShop development in 2012. With every project release, I always do a couple of things related to PrestaShop cache.

Not only is cache an issue when you a releasing your project publically, but when you install some addons or tweak something on your store.

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

Is It Safe To Remove PrestaShop Cache Folders

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

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

Where those folders are? Well, if you would scan all v1.7 PrestaShop source for cache folders you would find 54!

Difference Between Browser Cache and Server Cache

There are three types of caching basically:

Cache Type How To Remove Is It Safe To Remove
Browser Cache By hitting CMD+SHIFT+R or CTRL+SHIFT+R Yes
Server Cache By removing cache and temp folders Yes
PrestaShop Cache Usually 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 frontend, 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. Typical reset, when you just refresh page won’t do things. Still, hard reset informs the browser to ignore 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 in 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 that online scrappers cannot scan and download all images from your server at once.

How To Reset PrestaShop Cache

PrestaShop stores its and addons 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 - see next topic

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:

Config Value
Template compilation “Recompile templates if the files have been updated”
Cache Yes
Caching type File System
Clear cache “Clear cache everytime something has been modified”
Smart cache for CSS Yes
Smart cache for JavaScript Yes
Apache optimization Yes

Conclusion

Never run PrestaShop in production with 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 PrestaShop Customizations blog category.