4

I have some very simple Ubuntu server setups with NGINX passing requests for PHP files via PHP-FPM.

However, on two different servers, I've had the situation where http requests from browsers are being served old versions of the PHP files, missing updates to the PHP scripts that have been uploaded to the server.

In both cases, through trial and error, I found that only restarting PHP-FPM solves the problem. Once PHP-FPM is restarted, the new files are served. Until that point, only old files are served.

e.g. I go to mysite.com and see "Hello". I go to my server and edit index.php to say "Hello World" and save it. I clear my browser cache and go back to mysite.com and still see "Hello". I restart PHP-FPM and now I see "Hello World".

Can anyone explain why? I didn't think PHP-FPM did any internal caching, so why would it keep serving the content of old files which no longer exist in that form on the server?

6
  • 2
    In your php.ini, is the opcache.enable setting 0 or 1? Nov 14, 2019 at 14:40
  • @JeremyHarris It's commented out, so I guess that's off?
    – Ambulare
    Nov 14, 2019 at 14:52
  • 1
    The default value is "1" (i.e. turned on), so if it is commented out, then your opcache is enabled by default. Try explicitly setting it to 0 and let me know. php.net/manual/en/opcache.configuration.php Nov 14, 2019 at 14:54
  • 1
    exact same issue here, does setting opcache.enable setting to 0 fix it?
    – ben.IT
    Apr 29, 2021 at 13:28
  • @JeremyHarris @ben.IT thank you! I had the same issue and setting opcache.enable to 0 fixed it.
    – sho
    Aug 1, 2022 at 14:38

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.