문제

I've never really given this much thought, but curious what exactly goes on when I do a php include (or require).

I always assumed that when a php page is loaded, instead of actually including the file (and hitting disk) it checks a memory cache for the PHP compiled code (ie APC).

But then I was thinking, how does PHP know when the file has changed (and thus recompiled)? Doesn't it need to check the disk on load? Is this why (according to APC, disk hits, and requires/includes) including relative file names are worse than absolute because it has to check it's current directory for the absolute path (in case there are two files with the same name?) If so, that sounds like on some very big frameworks there would be a lot of disk hits checking to see if files have changed.

Or does this mean that if APC is turned on does this you have to clear the cache manually when you start it?

도움이 되었습니까?

해결책

Check out the documentation for apc.stat:

http://www.php.net/manual/en/apc.configuration.php#ini.apc.stat

This defaults to on, forcing APC to stat (check) the script on each request to determine if it has been modified. If it has been modified it will recompile and cache the new version. If this setting is off, APC will not check, which usually means that to force APC to recheck files, the web server will have to be restarted or the cache will have to be manually cleared.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top