support

Author Topic: Clearing cache automatically  (Read 3519 times)

Offline barry819

  • Jr. Member
  • **
  • Posts: 65
  • Karma: +4/-1
    • View Profile
Clearing cache automatically
« on: December 04, 2024, 02:30:32 PM »
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?
« Last Edit: December 04, 2024, 02:49:01 PM by barry819 »

Offline Basara

  • Administrator
  • Hero Member
  • *****
  • Posts: 6142
  • Karma: +284/-2
    • View Profile
Re: Clearing cache automatically
« Reply #1 on: December 05, 2024, 01:22:02 AM »
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.

Offline perplexed

  • Newbie
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: Clearing cache automatically
« Reply #2 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,

Offline Basara

  • Administrator
  • Hero Member
  • *****
  • Posts: 6142
  • Karma: +284/-2
    • View Profile
Re: Clearing cache automatically
« Reply #3 on: June 11, 2025, 01:39:32 AM »
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,
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: [Select]
<?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);
}

and set a CRON job to run it like
Code: [Select]
*/6 * * * * /usr/bin/php /home/public_html/clean_cache.php >/dev/null 2>&1

Offline perplexed

  • Newbie
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: Clearing cache automatically
« Reply #4 on: June 11, 2025, 03:22:50 PM »
Thank you. I am not dev person, but will do my best to try this.....

Offline OlivierPratt

  • Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Re: Clearing cache automatically
« Reply #5 on: Today at 02:04:30 AM »
Ambil langkah pertama menuju kemenangan besar dengan mendaftar hari ini!
newbielink:https://neon.ly/pRo1q [nonactive] | newbielink:https://neon.ly/NKX16 [nonactive] | newbielink:https://neon.ly/VLL2x [nonactive]

 

Powered by SMFPacks Social Login Mod