How To Turn Off Or Turn On The Smarty Cache
This post is an introduction to PrestaShop Smarty cache. This is a tip for the beginner PrestaShop owner or developer.
Basic Information About Smarty
Smarty is PHP template engine, with Smarty, you are able to separate business/program logic from your GUI design(theme or template). PrestaShop utilizes the Smarty engine so that you are able to switch/change your PrestaShop theme easily. The theme files (GUI design) are saved in separated themes folder, and with .tpl file extension.
For example (PrestaShop standard theme)
YourStoreRoot/themes/prestashop/header.tpl
YourStoreRoot/themes/prestashop/footer.tpl
But in order to make your theme file work, it has to be compiled into native PHP code before your web server can render the page HTML contents to your browser client. Compiling the themes file will reduce your server performance. In order to minimize the performance hit, PrestaShop uses Smarty functions so that the compilation is done only at the first execution of the theme files.
Potential Issues
As mentioned above, when smarty cache is turned on, the compilation will only be done at first execution of the theme files. This means that when you make changes to the theme files, the new changes you applied to the theme files may not take effect.
By default, the Smarty cache is turned on after you install your PrestaShop. If you do not know whether the Smarty cache is active, you may not know why your changes to theme files are not reflected on your PrestaShop pages. If you want to make changes and test the changes, you will have to turn off the smarty cache temporary.
PrestaShop 1.3x or lower
To switch smarty cache in PrestaShop 1.3x or lower, you need to change following two lines in smarty configuration file as listed below
Configuration file location:
YourStoreRoot/config/smarty.config.inc.php
To turn off, change the following lines as follows (when your make changes on your store theme files):
$smarty->caching = false;
$smarty->force_compile = true;
To turn on, change the following lines as follows (when your store is in production mode, no changes will be made):
$smarty->caching = true;
$smarty->force_compile = false;
PrestaShop 1.4x
If you are using PrestaShop 1.4x or higher, you do not need to change the files directly, you can instead make changes from your back office.
Log in to your back office, hover over or click the Preferences tab, click Performance option, then switch the smarty cache on or off and click "Save" button".
PrestaShop 1.5x
For PrestaShop 1.5x, the back office menu is arranged differently compared with PrestaShop 1.4x. You can find the same configuration options here:
Back office --> Advanced parameters --> Performances