Menghapus (flush) cache Magento 1 langsung dari command line

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();'
Magento 1 : Flush
Magento 1 : Flush

Penjelasan :

php -r : Menjalankan kode PHP satu baris langsung dari CLI, tanpa file .php.

require “../app/Mage.php”; :

  • Memuat core Magento

  • Mage.php adalah bootstrap utama Magento 1

  • Path ../app/Mage.php artinya : file dijalankan dari folder tertentu (biasanya shell/)

📌 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

About air

Periksa Juga

Magento : Mencari Tabel dengan Kolom Dimaksud

Magento : Mencari Tabel dengan Kolom Dimaksud

Mencari Tabel dengan Kolom Dimaksud di Magento

Leave a Reply

Your email address will not be published. Required fields are marked *