Saturday, December 31, 2022

Programmatically cache clear in PrestaShop 1.6 , 1.7 | PrestaCraft

Programmatically cache clear in PrestaShop 1.6 , 1.7 | PrestaCraft

🔥 Save unlimited web pages along with a full PDF snapshot of each page.
Unlock Premium →

Today I will show you how to programatically clear cache in PrestaShop. For example, you can make a CRON task which will execute this little PHP script once or more per day – depending on your needs.

1. Create PHP file in your store root (main) directory and name it as you wish – in this example it'll be cache_clear.php
2. Open this file and paste

include('./config/config.inc.php');    $token = Tools::getValue('token');    if($token == "vBnmmP3218") {      Tools::clearSmartyCache();      Tools::clearXMLCache();      Media::clearCache();      Tools::generateIndex();      echo "Cache clear ended successfully.";  } else {      echo "Wrong security token - cache clear failed.";  }

3. Change the string vBnmmP3218 to your random one (stronger is more secure).
4. Save the file.
5. Add script URL to your CRON task manager or execute it directly via your browser in format: http://{your_store_url}/cache_clear.php?token=vBnmmP3218

For example: http://example.com/cache_clear.php?token=vBnmmP3218

Source: https://prestacraft.com/programmatically-cache-clearing-in-prestashop/#
This web page was saved on Saturday, Dec 31 2022.

Upgrade to Premium Plan

✔ Save unlimited bookmarks.

✔ Get a complete PDF copy of each web page

✔ Save PDFs, DOCX files, images and Excel sheets as email attachments.

✔ Get priority support and access to latest features.

Upgrade now →