2

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.

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
panther1
  • 115
  • 9
  • 2
    Disabling history does not prevent caching. Try CTRL +F5 when refreshing the page or set headers via PHP/ Apache that will prevent the page from being cached. – Iansen Mar 27 '16 at 18:32

3 Answers3

6

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

Jota Martos
  • 4,548
  • 3
  • 12
  • 20
  • Hi Jota, thanks for the support, I use Bitnami Wordpress installed on EC2 and I flush the opcache based on my dev IP when I need to debug or do some tests. Your clients might need it as well. I have posted a piece of code. – RafaSashi Feb 17 '17 at 11:32
1

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.

RafaSashi
  • 16,483
  • 8
  • 84
  • 94
1

OPCache is causing it, on by default. It's useful to keep on, so what I do is just call "opcache_reset();" on any files I'm working in and then remove after I'm done. Works fine.

Chad French
  • 61
  • 2
  • 4