Every single time I am trying to upload a few photos, the Cache says "One or more of the Cache Types are invalidated: Blocks HTML output. Click here to go to Cache Management and refresh cache types." I know that you can go in and select all to refresh or flush, but if I try to go to the cache management page or any page in the website, a white page saying "This page isn’t working" pops up until I clear the cache through cpanel FTP or wait for a good few minutes to reload the page. Is there any solution to this?
<?php include 'app/Mage.php'; Mage::app(); ini_set('display_errors', 1); Mage::app()->getCacheInstance()->flush(); echo "cleared cache"; ?>
Answering the question assuming you are using Magento 1.
Check function invalidateType in file app/code/core/Mage/Core/Model/Cache.php
This function marks the cache as invalidated. You can hook the code of this function to clean the cache instead of marking it as invalidated.
I hope it will help.