I am very very new at PHP programming.
I am making up some code to test my learning but I just discovered a very annoying problem.
I have no idea about the cause, so following I'll describe my situation and I'll leave to you the "honor" to find the problem :)
I use dreamweaver to write my PHP code.
Once I made all the changes, I save the file and refresh the browser page to see the result.
Well, here is the problem. For like 30seconds nothing changes, after this time delay the page actually refreshes. There seems to be a delay between when I save the modified file in dreamweaver and when the browser (Chrome in my case) sees the new file.
I tried different browsers and I also verified that the file is physically changed...I have no clue.
It has nothing to do with Dreamweaver.
You have to disable OPCache
Some software such as MAMP turns on OPCache by default in the php configuration file (php.ini), you can disable it this way
opcache.revalidate_freq=0
Related
I recently ditched XAMPP on my Windows 10 machine and re-installed Apache (2.4), PHP 7 and MySQL manually (I followed the instructions given here in order to be able to switch between PHP versions easily).
Everything works fine, except that now when I make a change in a PHP file and hit Refresh in the browser, the change often doesn't appear immediately in the browser. No matter how hard I hit F5 (or Ctrl+F5), I still get the non-modified source code, and I have to wait a couple of minutes before those change are finally visible to the browser.
Needless to say, it's quite annoying when developing. And it didn't happen when I was using XAMPP.
So there seems to be some kind of cache somewhere, but I can't find where it is. I don't know if it's Apache or PHP, although I suspect it might be PHP, because the CSS or JS files are not affected by this problem (as far as I can tell).
Any idea what's causing this behavior and how to disable it?
EDIT: I did some more testing.
I created the simplest PHP file possible. Just:
<?php
echo 'test1';
I can confirm that the problem occurs even in this simple case (changing "test1" to "test2": the browser still shows "test1" for a while).
Opening the same page in another browser still shows the outdated code (test1 instead of test2).
Clearing the browser cache doesn't help.
So the problem doesn't seem to happen on the client side.
However, if I do the same test with an HTML file instead of a PHP file, then the problem doesn't occur. Any change done to that file is visible immediately in the browser (of course I'm still accessing this file via Apache, so http://localhost/some-path/test.html)
So the problem seems to affect only PHP files.
It seems the problem was caused by the OPCache module, which I had to enable in order to work on another (drupal 8) project.
In php.ini, the following line:
; How often (in seconds) to check file timestamps for changes to the shared
; memory storage allocation. ("1" means validate once per second, but only
; once per request. "0" means always validate)
opcache.revalidate_freq=60
Changing 60 to 1 (and restarting Apache) basically solved the problem.
Often times while working in Netbeans the changes I make in my code are not visible in the actual project. I'm working on a website using HTML/PHP and a lot of times, I make certain changes to my code, save it and then when I open the website in my browser it's like I never made any changes. It's really frustrating. Please help.
PS: I've noticed it mostly happens when I make changes to the CSS file.
First I would think of blaming Netbeans. Or you for not letting Netbeans upload changes to the server on Save.
But if it is mostly CSS (and I suppose Javascript), I would think of caching by your browser.
You can try Ctrl-F5 -in your browser- for forced refresh.
Or set the cache settings on your development server so, that a file is never cached
I'm currently testing a web application and kept noticing my changes weren't being updated after each save of the PHP file.
As far as I'm aware, I'm using no current PHP caching solution. I'm running PHP 5.5.3 with a fresh copy of CodeIgniter.
Here's what happened:
I noticed PHP didn't seem to be loading the latest code changes as I made them
After noticing the problem, I output <?php echo time();?> into all my view files
Now, the time updates on every page load - indicating PHP is processing each page's code
But still sometimes the page code updates don't take place until 3-5 page loads later
I've tried disabling and empty my browser cache multiple times
Am I right in thinking this is a PHP issue rather than a browser one, given the fact that the time() output is being updated?
PHP doesn't cache anything.
If time() is being updated, you know that there isn't a traditional cache issue.
It's possible you are dealing with filesystem caching if you are using something like NFS. That would explain the 3-5 second delay.
Well that was frustrating. Turns out that MAMP now installed and enables, by default, Zend OpCache - see Stop caching for PHP 5.5.3 in MAMP
I really need help on this one.
I am working on a site and made some changes on some lines, but after I uploaded it there were no changes happening. I have cleared my cache, even did ccleaner and a restart. Open the file again via ftp and the code is there but when I go to the site nothing has changed. I have also tried different browsers.
Sorry for bad English, but I really needed your help.
edit 1: i have tried deleting the file and i get 404 page. But when i uploaded it again, with the changed code, it display no changes at all again.
edit 2: i really think it's on the server side problem and any idea about it would be helpful, not some file being misplaced or something. i know i am working with the same file and put it on the right folder.
EDIT 3: SOLVED, the technical personnel said that the server is running eaccelerator and mtime was disabled and was causing the problem.
Correlate to a localhost (xampp or similar), i.e. if you don't see the same issue than you know it must be a transfer issue. Divide and Conquer in this manner to troubleshoot.
Strange bug here... ajax has been loading slow on this server since day one... we thought it was the internet connection, until yesterday. I accidentally added an invalid extension into the php.ini file (ie. extension=php_pdf.dll), and then all of a sudden, the ajax loaded extremely fast. When I took out that invalid extension, the ajax loaded slow again. My colleges and I did not create the php config file, so I'm not sure why this is happening... maybe there's a setting turned on in the php config file that is causing the ajax to load slow, and when this invalid extension is included, it skips the setting... not sure. But hopefully someone can help explain this!
If anyone can point me in the right direction to why this is happening, I'd appreciate it! Our slow ajax loading won't be fixed until this is sorted out, and the guy who created the php.ini file no longer works here.
The site is: link text
So if you click there, you'll see how slow the ajax loads. Please help, I can include the php.ini file if anybody wants to see what settings are enabled.
Thanks in advance to any help I receive.
You may want to install firebug if you are not using it already (it's a webdeveloper plugin for firefox).
I just checked out the site and the data seems to be loading fast enough but it seems the JS is just terribly slow. A hint that something is wrong is also in the net tab that doesn't seem to be able to determine the size of your ajax calls, if the js has that same problem it could cause it to hang waiting for the stream to end.
Looks like misconfiguration in the php.ini, but without its content it is hard to say anything about it really.
Also, if you try to load the ajax call manually, you'll see that the page loads for a long time, but the data shows up almost instantly, and then the connection is not closed immediately.
If you are sure the commenting out of the bad dll declaration is having a bearing on this issue, you could try moving it down the list till you find out which other dll is causing the problem.
Did you look in the php start up errors?
ini_set('display_errors','1');
ini_set('display_startup_errors','1');
error_reporting (E_ALL);