cakephp - why do some changes NOT happen until I switch debugging to 3?

前端 未结 6 1619
予麋鹿
予麋鹿 2020-12-06 01:17

Sometime I will implement changes locally and they work fine, I copy them to my remote webserver and the changed are ignored. (The code is identical.)

I go into core

6条回答
  •  鱼传尺愫
    2020-12-06 01:46

    I have found wonderful solution here. I think it should be perfect and working fine. The solution like below:

    function _clear_cache()
        {
    
            Cache::clear();
            clearCache();
    
            $files = array();
            $files = array_merge($files, glob(CACHE . '*')); // remove cached css
            $files = array_merge($files, glob(CACHE . 'css' . DS . '*')); // remove cached css
            $files = array_merge($files, glob(CACHE . 'js' . DS . '*'));  // remove cached js
            $files = array_merge($files, glob(CACHE . 'models' . DS . '*'));  // remove cached models
            $files = array_merge($files, glob(CACHE . 'persistent' . DS . '*'));  // remove cached persistent
    
            foreach ($files as $f) {
                if (is_file($f)) {
                    try {
                        @unlink($f);
                    } catch (Exception $ex) {
                        $files['errors'][] = $ex->getMessage();
                    }
                }
            }
    
            if (function_exists('apc_clear_cache')):
                apc_clear_cache();
                apc_clear_cache('user');
            endif;
    
            return $files;
    
        }
    

    Just use above function in your appcontroller and run that function where you want it will be clear all cache.

提交回复
热议问题