問題描述
在帶有 PHP 5.5.3 的新 Macbook 上安裝 MAMP.
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 back and refresh. It works. What the heck?
我進入 php.ini 并禁用所有新的 OPcache 并將默認緩存時間設置為 0.向文檔添加標題以強制不緩存.還是一樣的問題.這到底是怎么回事?
I went into php.ini and disabled all the new OPcache and set the default cache time to 0. Added headers to the document to force no caching. Still same problem. What the heck is going on here?
網絡選項卡顯示 HTTP 200 請求,因此 index.php
文件中的任何新 HTML 都可以正常呈現,但需要由服務器呈現的新 PHP 被延遲并且直到一些預定的時間過去了,我不知道如何改變.怎么回事?
The network tab is showing a HTTP 200 request, so any new HTML in the index.php
file renders fine, but new PHP that needs to be rendered by the server is delayed and not rendered until some predetermined set of time passes that I don't know how to change. What's going on?
我也在 Safari 中檢查了這個,所以它肯定是服務器的事情阻止了文件的呈現.
I checked this in Safari too so it is definitely a server thing that is keeping the file from rendering.
有趣的事實是,如果我進入 MAMP 并將 PHP 版本更改為舊版本(PHP 5.2 或其他版本),它將正常呈現,沒有緩存問題".切換到 PHP 5.5,它掛了.在 MAMP 首選項中,5.5 的緩存選項甚至不存在并且會自動禁用.
Interesting fact though, if I go into MAMP and change the PHP version to the old one (PHP 5.2 or something) it will render normally, with no "caching issues". Switch to PHP 5.5 and it hangs up. In the MAMP preferences caching options for 5.5 don't even exist and are automatically disabled.
推薦答案
禁用 OPCache
MAMP 現在默認開啟 OPCache,你可以通過編輯你的 php.ini 文件來禁用它.確保您編輯了正確的 php.ini.
MAMP now turns on OPCache by default, you can disable it by editing your php.ini file. Make sure you edit the correct php.ini.
我自己也遇到了同樣的問題.默認情況下,PHP 5.5.3 版的 MAMP 運行 OPcache,但您無法像使用舊版 PHP 5.2.17 那樣在 GUI 中關閉它.您必須手動注釋掉 php.ini 文件(MAMP/bin/php/[version]/conf/php.ini)末尾的所有 OPcache 行,并確保停止和啟動服務器以進行更改效果.
I was running into the same problem myself. MAMP with PHP version 5.5.3 runs OPcache by default, but you can't turn it off in the GUI like you can with the older PHP version 5.2.17. You have to manually comment out all the OPcache lines at the end of the php.ini file (MAMP/bin/php/[version]/conf/php.ini) and make sure to stop and start the servers for the changes to take effect.
我更新了 URI,更改也可以通過更改 php 文件夾下的/conf/來反映,但似乎 MAMP 在重啟后會忽略這些.
這篇關于在 MAMP 中停止緩存 PHP 5.5.3的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!