Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why won't the page refresh with MAMP

I just bought a brand new macbook pro, and installed MAMP on it. All the files are saved in the right location /htdocs and the first time I ran my PHP files, everything was working fine. Then when I changed the script and ran it again, the browser wouldn't reload the page, it would display the old (cached?) version of the file.

I tried doing a hard refresh, a browser restart, a different browser, a server restart but none of that seems to work.

like image 876
Kegan Quimby Avatar asked Aug 15 '11 03:08

Kegan Quimby


3 Answers

There is a cache, in your MAMP preferences if you use the php version 5.5.3. The same thing happen to me, I found the solution there: MAMP time between seeing live changes

In your MAMP Dir go to : /bin/php/php5.5.3/conf/php.ini
And comment the Opcahe lines:

[OPcache]
;zend_extension="/Applications/MAMP/bin/php/php5.5.3/lib/php/extensions/no-debug-non-zts-20121212/opcache.so"
;  opcache.memory_consumption=128
;  opcache.interned_strings_buffer=8
;  opcache.max_accelerated_files=4000
;  opcache.revalidate_freq=60
;  opcache.fast_shutdown=1
;  opcache.enable_cli=1
like image 172
coding addicted Avatar answered Nov 13 '22 12:11

coding addicted


The same thing was happening to me a few months ago. Here's the solution that worked for me: Go to preferences in MAMP, and change the Apache Port to 80, and the MYSQL port to 3306, then restart the server and try loading your PHP.

like image 22
austinb Avatar answered Nov 13 '22 11:11

austinb


Further to the answer provided by coding addicted, and specific to people using MAMP PRO... on current versions of MAMP PRO (I see on mamp.info that it's not an option on the free MAMP) you have the option to just disable the PHP cache.

You can access it from the shortcut in the PHP tab in MAMP PRO. Or, browse to http://localhost:8888/MAMP/opcache.php# (changing the hostname and port to match your configuration).

enter image description here

I should also be noted that MAMP PRO (at least recent versions) uses a dynamically generated php.ini file, so you can't edit it in your local file system.

MAMP has the following to say about editing the files directly,

"You must always use the template functions of MAMP PRO to edit the configuration files of the MAMP subsystem. If you change them bypassing MAMP PRO your changes will most likely be ignored or overwritten the next time the servers start."

Instead, in MAMP PRO, go to FILE > Edit Template > PHP > [select the php version you wish to edit] and make the required changes there. Of course, in light of the info I gave above, this is not really necessary if you're simply wishing to prevent OPCACHE from holding back your updated code output. Just disable OPCACHE in the interface.

You can also switch to using APC or XCache, as I notice neither of those delay the refresh of code output.

like image 24
inspirednz Avatar answered Nov 13 '22 13:11

inspirednz