Perintah berikut adalah perintah PHP CLI untuk menghapus (flush) cache Magento 1 langsung dari command line :
php -r 'require "../app/Mage.php"; Mage::app()->getCacheInstance()->flush();'

Penjelasan :
php -r : Menjalankan kode PHP satu baris langsung dari CLI, tanpa file .php.
require “../app/Mage.php”; :
-
Memuat core Magento
-
Mage.phpadalah bootstrap utama Magento 1 -
Path
../app/Mage.phpartinya : file dijalankan dari folder tertentu (biasanyashell/)
📌 Jika kamu ada di root Magento, path-nya biasanya :
require "app/Mage.php";
Mage::app() :
-
Menginisialisasi aplikasi Magento
-
Load config, store, dan environment
getCacheInstance()->flush() :
-
Menghapus SEMUA cache Magento
-
Termasuk:
-
Config cache
-
Layout cache
-
Block HTML cache
-
Collection data cache
-
⚠️ Tidak menghapus:
-
Session
-
Media cache
-
Full Page Cache eksternal (Varnish)
-
✅ Fungsi Utama Perintah Ini
✔ Sama dengan System → Cache Management → Flush Magento Cache
✔ Berguna jika:
-
Admin panel tidak bisa diakses
-
Cache error / corrupt
-
Setelah deploy / reindex
🆚 Perbandingan dengan Cara Lain
Cara Efek rm -rf var/cache/*Hapus file cache saja Mage::app()->getCacheInstance()->flush()Hapus cache via API Magento (aman) Flush Cache Storage Lebih dalam (Redis/Memcached)
🔧 Contoh Pemakaian Aman
Dari root Magento :
php -r 'require "app/Mage.php"; Mage::app()->getCacheInstance()->flush();'
Dari folder shell/ :
php -r 'require "../app/Mage.php"; Mage::app()->getCacheInstance()->flush();'
⚠️ Peringatan Penting
-
Jangan jalankan saat traffic tinggi
-
Cache akan rebuild → website bisa terasa lambat sementara
-
Pastikan path Mage.php benar
Andhi Irawan My Personal Blog