I'm using MAMP server and wondering why changes I make to the PHP files are not instantaneously displayed when I page refresh (in browser). Is there a way to set this up? There are no caching settings on MAMP. Either I have to wait 20 seconds or stop and restart the server.
Asked
Active
Viewed 2.5k times
42
-
The closest to your problem I have experienced is when using Chrome my JS/css files don't refresh immediately and just pull from cache unless I explicitly clear my browser cache. Firefox tends to do better (CMD+SHIFT+R to force reload works in FF, not in Chrome). Even if Chrome is not your problem it is probably a cache issue. MAMP has 0 delay in serving modified content and by default does not enable any weird cache settings. – Levi Sep 29 '13 at 14:22
-
5`There are no caching settings on MAMP` -- you sure? Preferences -> PHP -> Cache -> select '__' -> OK -> Restart MAMP. -> ... -> Profit! – Amal Murali Sep 29 '13 at 14:23
-
Yes, @Amal, I found that option before and it's set to nothing. Thanks though. And I've opened the site in incognito to make sure browser wasn't caching. This is just weird because I haven't encountered this on my work Mac which I've set mamp upon. And WAMP has no same issue on my pc. – zebapy Sep 29 '13 at 15:02
-
Okay, so this issue happens when you use php 5.5 but 5.2 it doesn't happen. What gives? – zebapy Sep 29 '13 at 17:26
-
Think you could accept my answer if you want. Seems to answer the question for a lot of people as the amount of votes rises. Or is your issue still not totally fixed? – Luc Franken Jan 10 '14 at 10:21
3 Answers
85
The solution is to comment out lines in the php.ini file which can be found in /MAMP Directory/bin/php/php5.5.3/conf/php.ini
Comment out Opcache:
[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
Documentation (yes it started in 5.5):

Luc Franken
- 2,994
- 1
- 17
- 14
-
3Thanks. Or simply just select a lower php version in MAMP's setting. – Cullen SUN Dec 19 '13 at 02:56
-
Off course, if you don't need 5.5 that will work since it has been implemented since 5.5. This answer fits the issues just for 5.5. – Luc Franken Dec 19 '13 at 08:38
-
I have this problem and my PHP version is 5.3. There is no folder you specify and no opcache. – user734063 Apr 03 '14 at 22:02
-
The problem started with 5.5, see: http://www.php.net/manual/en/intro.opcache.php that's why this solution works on 5.5. If you have the same issue you might run into another problem. But first test whether you have: The right PHP.ini file (test with phpinfo() by changing some settings (reload server!) and confirm you are sure to use 5.3. If the problem remains you might have a totally different issue most likely because opcache just wasn't there at earlier versions. MAMP also has some other caching tricks and your code might have some so I would start looking there after checking php.ini. – Luc Franken Apr 03 '14 at 22:15
-
I just installed Mamp 3.4 under 10.6.8 and things look different so that, being totally ignorant is such matters, I am afraid to improvise. Mamp preference gives me the choice between php 5.2.6 and 5.5.6 with the latter checked. Cache is off but gives me the choice among APC, Xcache and OPcache. What I would like is for Mamp to reload when I save in Smultron the way Cyberduck reloads the website. – schremmer Nov 23 '15 at 03:47
-
@schremmer am I right to say that's a totally different issue? auto-reload or hot-code-reload like functions are a totally different thing compared to the issue discussed and answered here? Or is there a relevance? – Luc Franken Nov 23 '15 at 09:23
-
@LucFranken You are probably right. What made me ask here is "why changes I make to the PHP files are not instantaneously displayed when I page refresh (in browser)" in the OP. Could you direct me? – schremmer Nov 24 '15 at 19:15
-
@schremmer That's not what happened here, here it even blocked on reloading the page. I suggest that it's better to create a new question since your question does not seem related. – Luc Franken Nov 25 '15 at 18:29
-
I have faced the same issue, Why should you have to comment it out? Opcode cache is good for performance, so if you have to disable it then its either MAMP's fault or something else is wrong – Mar 17 '20 at 19:40
-
This solution is wrong. It says to UNCOMMENT lines in the PHP ini file, but you actually need to COMMENT those lines out. – briann Feb 16 '22 at 07:47
19
The Luc's answer is correct. There is an easier way to disable cache in Mamp (as of version 6.5).
- Launch Mamp
- Click Preferences
- in PHP-Cache select off

Saqib Omer
- 5,387
- 7
- 50
- 71
-
1
-
2This fixed my caching issue in MAMP for MacOS with PHP 7.4.21. I tried Luc's answer but my OPcache was already all commented, so this answer saved the day. Thanks – noxter Dec 14 '22 at 08:59
-
@noxter Same here, only I first commented-out an irrelevant PHP version (not my active one)... But then I saw MAMP's own (Mac) reference, https://documentation.mamp.info/en/MAMP-Mac/Preferences/General/ which shows the above dialogue so I re-invented Saqib's solution and it did the trick. – user3445853 Feb 12 '23 at 23:33
5
The accepted answer doesn't apply to more recent PHP version (e.g. PHP 7.4), where opcache is enabled by default.
To disable opcache, edit the php.ini file located at (change the php version to the one you're using):
/Applications/MAMP/bin/php/php7.4.21/conf/php.ini
Change the following line:
;opcache.enable = 1
Into:
opcache.enable = 0
That solved the problem.

ingdc
- 760
- 10
- 16