takes many refreshes before server side code is updated?

巧了我就是萌 提交于 2019-12-14 02:05:35

问题


I am using Bitnami WAMP Stack. Whenever I edit a php file in my IDE(I am using netbeans, have also tried phpstorm), it take 4-5 refreshes in the browser, before the page is updated. I first though that it was a cache issue in Google Chrome, but, I also tried Mozilla Firefox with history disabled. Still have the same problem.

Any ideas, what could be causing this?

P.S: this happens with server side code too.. eg. Controllers in Laravel.


回答1:


Bitnami developer here,

If you are developing on top of an AMP Stack, your files (like JavaScript files) may be cached by the server and even you modify them your changes will not appear to be applied.

In order to disable cache in the server and let the files being served each time you need to disable OPCache, enabled by default in PHP.

To disable it, change opcache.enable in your php.ini file and set it to 0 (installdir/php/php.ini)

After that, restart the services of the installation.

You can learn more about this in the following link.

I hope it helps. Jota




回答2:


In addition to Jota Martos's answer if you want to keep opcache enabled and flush it only on your development environment you can use this:

/** development environment */

if(!function_exists('is_dev_env')){

    function is_dev_env( $dev_ip = '176.136.10.100' ){

        if( $_SERVER['REMOTE_ADDR'] == $dev_ip || ( isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR'] == $dev_ip ) ){

            return true;
        }

        return false;       
    }           
}   

/** flush opcache */

if( is_dev_env() ){

    opcache_reset();
}

Replace 176.136.10.100 by your current user IP

I use this on my EC2 Bitnami Wordpress installations at the very beginning of wp-config.php for example.



来源:https://stackoverflow.com/questions/36250656/takes-many-refreshes-before-server-side-code-is-updated

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!