eCommerce construction > Installation and Configuration
Clearing cache automatically
barry819:
Is there a setting to peridoically clear cache?
here's the problem: my hosting package sets a limit on iNodes. Cache consumes iNodes, and as a result peridoically my site gets disabled (customers cannot place orders because they cannot add items to a shopping cart) unless I go in and manually clear all the site cache.
I'm on 1.3.3, and the cache clear function is only manual, there's no way to set the site to clear cache based on some time frame (daily, weekly, monthly, whatever).
Is there a setting somewhere that I have missed that would resolve this? Or an extension that could perform a periodic clear?
Basara:
Hello.
First, you need a script that will delete the cache files. For example a simple shell or php script. Upload the clear_cache.sh script to your server. Now, you need to set up a cron job in your hosting panel to run this script at regular intervals.
perplexed:
Hoping this message still gets some recognition. As this post is relevant to the problem we have with inodes filling up on our hosting site. However the script in this message is not a link just text. Anyone know where we can find this clear_cache.sh ?
Thank You,
Basara:
--- Quote from: perplexed on June 10, 2025, 12:24:07 PM ---Hoping this message still gets some recognition. As this post is relevant to the problem we have with inodes filling up on our hosting site. However the script in this message is not a link just text. Anyone know where we can find this clear_cache.sh ?
Thank You,
--- End quote ---
Hello.
Can you tell which version of AbanteCart you're using and the number of products you have?
You can create the clean_cache.php script like this
--- Code: ---<?php
// File: /home/public_html/clean_cache.php
$cacheDir = __DIR__ . '/system/cache';
// Ensure the directory exists
if (!is_dir($cacheDir)) {
exit("Cache directory not found: $cacheDir\n");
}
$files = scandir($cacheDir);
foreach ($files as $file) {
// Keep index.html and skip . / ..
if ($file === '.' || $file === '..' || $file === 'index.html') {
continue;
}
$filePath = $cacheDir . '/' . $file;
if (is_file($filePath)) {
unlink($filePath);
} elseif (is_dir($filePath)) {
deleteDirectory($filePath);
}
}
// Recursive deletion function
function deleteDirectory($dir) {
$items = array_diff(scandir($dir), ['.', '..']);
foreach ($items as $item) {
$path = "$dir/$item";
is_dir($path) ? deleteDirectory($path) : unlink($path);
}
return rmdir($dir);
}
--- End code ---
and set a CRON job to run it like
--- Code: ---*/6 * * * * /usr/bin/php /home/public_html/clean_cache.php >/dev/null 2>&1
--- End code ---
perplexed:
Thank you. I am not dev person, but will do my best to try this.....
Navigation
[0] Message Index
[#] Next page
Go to full version