为什么MAMP页面不刷新
我刚买了一台全新的 macbook pro,并在上面安装了 MAMP。所有文件都保存在正确的位置 /htdocs 中,第一次运行 PHP 文件时,一切都工作正常。然后,当我更改脚本并再次运行它时,浏览器不会重新加载页面,它会显示文件的旧(缓存?)版本。
我尝试进行硬刷新、浏览器重新启动、不同的浏览器、服务器重新启动,但这些似乎都不起作用。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您使用 php 版本 5.5.3,则在您的 MAMP 首选项中会有一个缓存。
同样的事情也发生在我身上,我在那里找到了解决方案: MAMP 看到实时更改之间的时间< /a>
在您的 MAMP 目录中,转到:/bin/php/php5.5.3/conf/php.ini
并评论 Opcahe 行:
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:
几个月前,同样的事情也发生在我身上。这是对我有用的解决方案:
转到 MAMP 中的首选项,将 Apache 端口更改为 80,将 MYSQL 端口更改为 3306,然后重新启动服务器并尝试加载 PHP。
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.
根据编码成瘾提供的答案,以及特定于在当前版本的 MAMP PRO 上使用 MAMP PRO 的人(我在 mamp.info 上看到它不是免费 MAMP 上的选项),您可以选择禁用 PHP 缓存。
您可以通过 MAMP PRO 中 PHP 选项卡中的快捷方式访问它。或者,浏览到
http://localhost:8888/MAMP/opcache.php#
(更改主机名和端口以匹配您的配置)。我还应该注意的是,MAMP PRO(至少是最近的版本)使用动态生成的
php.ini
文件,因此您无法在本地文件系统中编辑它。MAMP 对于直接编辑文件有以下说法,
相反,在 MAMP PRO 中,转到
FILE > Edit Template > PHP > [选择您要编辑的 PHP 版本]
并在其中进行所需的更改当然,根据我上面提供的信息,如果您只是希望阻止 OPCACHE 阻止更新的代码输出,那么您也可以切换到使用 。
APC
或XCache
,因为我注意到它们都不会延迟代码输出的刷新。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).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,
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
orXCache
, as I notice neither of those delay the refresh of code output.可能的答案:停止 MAMP 中 PHP 5.5.3 的缓存
对我来说,只是将 opcache_reset(); 添加到 php 脚本中
possible answer: Stop caching for PHP 5.5.3 in MAMP
for me, just worked adding opcache_reset(); to the php scritp