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.
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
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.