I use filemtime to print external resources in html, for example:
<link rel="stylesheet" href="screen-<?=md5(filemtime('screen.css'));?>.css">
I noticed a significant delay between the effective update and the timestamp returned by filemtime , so I added clearstatcache() at the top, which seems to solve the problem. But according to php manual :
you only need to call clearstatcache () if you are performing several operations with the same name and require a specific file that cannot be cached.
So I wonder if I use it correctly.
Also, I am concerned about the performance of completely clearing the cache on every call. Can someone tell me if this could cause a significant slowdown on the server?
clearstatcache also accepts two additional parameters, but I'm not sure about their meaning:
clear_realpath_cache Clear the cache of the real path or not.
file_name Clear realpath and stat cache for a specific file name. only; used only if clear_realpath_cache is set to TRUE.
I do not understand what the "realpath cache" is, and I could not find any information about it. Does it make sense to call clearstatcache as follows:
clearstatcache(true,'/path/to/screen.css');
with the intention of clearing only the information associated with this particular file (and therefore reducing the "impact" of clearstatcache )?
Giona
source share