i'm using filemtime
for fingerprinting external resources in html, like:
<link rel="stylesheet" href="screen-<?=md5(filemtime('screen.css'));?>.css">
I noticed a significant delay between the effective updating and the timestamp returned by filemtime
, so i added clearstatcache()
at the top, which seems to solve the issue. But according to php manual:
you only need to call clearstatcache() if you are performing multiple operations on the same filename and require the information about that particular file to not be cached.
So i'm wondering if i'm using it correctly.
Also, i'm concerned about the performance of fully clearing the cache on every call. Can anyone tell me if it can cause a significant slowdown in the server?
clearstatcache
also accepts two additional parameters, but i'm unsure of their meaning:
clear_realpath_cache Whether to clear the realpath cache or not.
filename Clear the realpath and the stat cache for a specific filename only; only used if clear_realpath_cache is TRUE.
I don't get what "realpath cache" means, and i couldn't find any information about it. Does it make any sense to call clearstatcache
this way:
clearstatcache(true,'/path/to/screen.css');
with the intent to clear only information related to that specific file (and therefore reduce the "impact" of clearstatcache
)?