Stop caching for PHP 5.5.3 in MAMP

前端 未结 9 1251
孤城傲影
孤城傲影 2020-11-27 10:03

Installed MAMP on a new Macbook with PHP 5.5.3.

Reload and refresh do nothing. Still nothing. Google around for a few minutes trying to find out what is wrong, come

相关标签:
9条回答
  • 2020-11-27 10:34

    This is also current in the Windows version of MAMP as well.

    C:\MAMP\conf\php5.6.3\php.ini

    It's listed at the very bottom of the file.

    The other problem I found, was on a QNAP NAS TS-431. This caching is also enabled, and if you are working with dynamically changing files, or try to develop on it, you'll be ripping out your hair. As per the other comments, just comment it out. The setting is located in:

    Control Panel/Applications/Web Server/PHP.ini Maintenance.

    Once again, you'll find the settings at the bottom of the file.

    0 讨论(0)
  • 2020-11-27 10:39

    Took me so long to figure out it was a MAMP problem! Why would OPcache be enabled by default-- and require php.ini tinkering to disable-- in an app that's supposed to be used for testing websites? Anyway, I read through this whole thread and tried the various solutions.

    Here are my notes on how each solution works and considerations for selecting a solution.

    Each solution works on its own; no need for redundancy.


    Webpage code solution

    opcache_reset();

    <?php opcache_reset(); ?>
    
    • Must be added in the webpage code.
    • Forces all scripts to be reloaded.
    • Works without restarting MAMP server.

    Server configuration solutions

    Important: Use the php.ini file in /Applications/MAMP/bin/php/php5.5.3/conf/php.ini and not in /Applications/MAMP/conf/php5.5.3/php.ini. Adjust accordingly if you're using a different version of PHP.

    enable=0

    [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
    enable=0
    
    • Must be added under [OPcache] in php.ini.
    • Disables OPcache.
    • Requires MAMP server restart.

    opcache.revalidate_freq=0

    [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=0
    opcache.fast_shutdown=1
    opcache.enable_cli=1
    
    • Modify opcache.revalidate_freq under [OPcache] in php.ini.
    • Makes OPcache check for updates every 0 seconds instead of every 60 seconds.
    • Requires MAMP server restart.

    Commenting 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
    
    • Comment out the entire [OPcache] section in php.ini.
    • Removes OPcache from the PHP server.
    • Requires MAMP server restart.

    Considerations

    Choose the webpage code solution if:

    • You just need to force script refreshing for a particular project
    • You don't want to restart the MAMP server
    • You don't want to edit php.ini

    Choose a server configuration solution if:

    • You want to disable caching by default instead of having to do it in every project
    • You're comfortable with editing php.ini

    I personally prefer enable=0 since it's the simplest solution for me, and I need caching disabled by default.


    References

    • http://php.net/manual/en/function.opcache-reset.php
    • http://php.net/manual/en/opcache.configuration.php
    0 讨论(0)
  • 2020-11-27 10:42

    MAMP 3.0.7.2 for OS X

    It looks like this is finally a GUI option. MAMP 3.0.7.2 for Mac OS X.

    0 讨论(0)
提交回复
热议问题