Clearstatcache + include_path + sessions

I have a problem when we run an update for our web application.

After the update, the script is completed and access to the web application through the browser is opened, we get the file of not found errors on require_once (), because we moved some files, and PHP still has the old directory structure, cached.

If the default expiration of realpath_cache_ttl is 120 seconds, then everything will resolve, but this is unacceptable for obvious reasons.

So I tried using clearstatcache with limited success. I created a separate file (clearstatcache.php) that calls this function only (single-line file), and put it in our installation script via curl:

<?php clearstatcache(true); 

This does not work, however, if I call this file through the browser, it immediately starts working.

I am running PHP version 5.3

I began to study the differences in request headers between my browser and curl, and the only thing I can see is that it matters in the cookie of the PHPSESSID file.

So my question is: is the current PHPSESSID problem (I don’t think it should). Am I something wrong with my curl script? I use

 curl -L http://localhost/clearstatcache.php 

EDIT:. After further research, I decided that this probably relates to several Apache processes. clearstatcache will only clear the cache of the current apache process - when the browser makes a request, another request processes another apache process, and this process still has the old cache.

+6
source share
1 answer

Given that the cache is part of the Apache child process thanks to mod_php, your solution will probably restart the Apache server.

If you used FastCGI (under Apache or another web server), the solution would probably restart any process manager that you used.

This step should probably be part of your standard deployment plan. Keep in mind that there may be other caches that you might also need to clear.

+1
source

Source: https://habr.com/ru/post/908274/


All Articles