简体   繁体   English

为什么页面不会用 MAMP 刷新

[英]Why won't the page refresh with MAMP

I just bought a brand new macbook pro, and installed MAMP on it.我刚买了一个全新的 macbook pro,并在上面安装了 MAMP。 All the files are saved in the right location /htdocs and the first time I ran my PHP files, everything was working fine.所有文件都保存在正确的位置 /htdocs 中,当我第一次运行 PHP 文件时,一切正常。 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.我尝试进行硬刷新,重新启动浏览器,重新启动不同的浏览器,重新启动服务器,但这些似乎都不起作用。

There is a cache, in your MAMP preferences if you use the php version 5.5.3.如果您使用 php 版本 5.5.3,则在您的 MAMP 首选项中有一个缓存。 The same thing happen to me, I found the solution there: MAMP time between seeing live changes同样的事情发生在我身上,我在那里找到了解决方案: MAMP time between seen live changes

In your MAMP Dir go to: /bin/php/php5.5.3/conf/php.ini在你的 MAMP 目录 go 到:/bin/php/php5.5.3/conf/php.ini
And comment the Opcahe lines:并评论 Opcahe 行:

[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

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. 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.

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.除了编码上瘾提供的答案之外,并且特定于在当前版本的 MAMP PRO 上使用 MAMP PRO... 的人(我在 mamp.info 上看到它不是免费 MAMP 的选项),您可以选择禁用PHP 缓存。

You can access it from the shortcut in the PHP tab in MAMP PRO.您可以从 MAMP PRO 中 PHP 选项卡中的快捷方式访问它。 Or, browse to http://localhost:8888/MAMP/opcache.php# (changing the hostname and port to match your configuration).或者,浏览到http://localhost:8888/MAMP/opcache.php# (更改主机名和端口以匹配您的配置)。

在此处输入图像描述

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 PRO(至少是最新版本)使用动态生成的php.ini文件,因此您无法在本地文件系统中编辑它。

MAMP has the following to say about editing the files directly, MAMP 对直接编辑文件有以下说法,

"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." “您必须始终使用 MAMP PRO 的模板功能来编辑 MAMP 子系统的配置文件。如果您绕过 MAMP PRO 更改它们,您的更改很可能会在下次服务器启动时被忽略或覆盖。”

Instead, in MAMP PRO, go to FILE > Edit Template > PHP > [select the php version you wish to edit] and make the required changes there.相反,在 MAMP PRO 中,go 到FILE > Edit Template > PHP > [select the php version you wish to edit]并在此处进行所需的更改。 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.当然,根据我上面提供的信息,如果您只是希望阻止 OPCACHE 阻止您更新的代码 output,那么这并不是必需的。 Just disable OPCACHE in the interface.只需在界面中禁用 OPCACHE。

You can also switch to using APC or XCache , as I notice neither of those delay the refresh of code output.您也可以切换到使用APCXCache ,因为我注意到它们都不会延迟代码 output 的刷新。

possible answer: Stop caching for PHP 5.5.3 in MAMP可能的答案: 停止缓存 MAMP 中的 PHP 5.5.3

for me, just worked adding opcache_reset();对我来说,刚刚添加了opcache_reset(); to the php scritp到 php 脚本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM