With PHP 7.4, support for preloading was added, a feature that could improve the performance of your code significantly.
In a nutshell, this is how it works:
- In order to preload files, you need to write a custom PHP script
- This script is executed once on server startup
- All preloaded files are available in memory for all requests
- Changes made to preloaded files won't have any effect, until the server is restarted
If you want more information, some article are available on this new feature.
library used (under MIT licence):
https://github.com/DarkGhostHunter/Preloader
1 / Mandatory Requirement
- Php 7.4 minimum version
- opCache installed
- An access to your php.ini
- Work in 777 chmod
2 / How to implement :
Step 1 : Know your path
You must know your root on preloader.php inside your application. below an example
www/var/..../shop/includes/ClicShopping/Work/Log/preloader.php
Step 2 : Php.init implementation
Edit your php.init and search this line :
;opcache.preload=
replace by your root path : below an example
opcache.preload=/home/www/..../shop/includes/ClicShopping/Work/Log/preloader.php
Step4 : Restart apache2
Make this command inside your terminal
sudo service apache2 restart
Step5 : Configure ClicShopping
* Go to ClicShopping Administration
- Menu Configuration / Session & Cache / Compression & optimization
- Activate the preload functionnalities
* Go to your catalog and actualise a page
- The sytem will create a preloader.php file inside your Work/Log directory
- You can check if everything is correct in editing your preload.php files. You must see some information inside.