PHP file will not update in browser
Solution 1
Your script cached in memory with opcache feature. Disable it in php.ini
:
opcache.enable = 0
But you also have to restart server. If you use hosting, use control panel to restart or try to change php version to another and revert.
Solution 2
Since this is the first result on Google when searching for this kind of issue, I'd like to add that if you have opcache enabled, you don't necessarily need to disable it completely.
You probably have opcache.validate_timestamps
set to 0
which will stop the automatic update of your files based on the last modification date.
Modify this parameter in your php.ini file:
opcache.validate_timestamps = 1
Restart the php-fpm service (or apache depending on your situation) and your script should be up to date at the next execution.
Comments
-
Hyunmin Kim almost 2 years
For some odd reason, every time I update a file, it is not updating inside a browser (localhost - wampserver). To be more specific. If I have a simple php script:
echo "hello world";
It runs fine in the browser, and shows the text 'hello world'.
However, if I update it to
echo "goodbye world";
And refresh the browser, nothing happens. The text remains 'hello world'.
This has not been a problem before and was refreshing perfectly. I tried clearing the browser cache, tested on multiple browsers, restarted my wamp server, and restarted the computer. Nothing seems to be working.
The only way the code seems to be updated is if I run the script from my IDE. Then it shows up in the browser with the updated code. How can this problem be fixed? I want it to go back to the way it was and be able to refresh from within the browser.
Using wampserver php - 5.3.13, apache 2.2.22
-
Leo Fisher over 5 yearsOr you can set opcache_reset() at head of script. secure.php.net/manual/en/function.opcache-reset.php