Tutorials, Development

Stop MAMP delay between saving and viewing changes

I’ve noticed recently when using MAMP to test PHP 7 that changes are not shown right away when looking at the browser. Sometimes it can be a few seconds before the changes are updated. That can be misleading if you don’t reliase it’s cached. 

Turns out from PHP 5.5 opcache is turned on my default

OPcache improves PHP performance by storing precompiled script bytecode in shared memory, thereby removing the need for PHP to load and parse scripts on each request.

This extension is bundled with PHP 5.5.0 and later

http://www.php.net/manual/en/intro.opcache.php

To turn it off located your php.ini file in my case it was located at my php/ect/php.ini and the opcache section and turn them off by placing a ; at the beginning.

[opcache]
;zend_extension=opcache.so
; Determines if Zend OPCache is enabled
;opcache.enable=1

Stop and start the server, once it’s back up no delay will occur.

 

David Carr

David Carr

For the past 12 years, I’ve been developing applications for the web using mostly PHP. I do this for a living and love what I do as every day there is something new and exciting to learn.

In my spare time, the web development community is a big part of my life. Whether managing online programming groups and blogs or attending a conference, I find keeping involved helps me stay up to date. This is also my chance to give back to the community that helped me get started, a place I am proud to be apart of.

Besides programming I love spending time with friends and family and can often be found together going out catching the latest movie, staying in playing games on the sofa or planning a trip to someplace I’ve never been before.