From time to time, the system does not find a file that exists From time to time (1 in 20 pages or so), I receive the following Drupal error:

Warning: file_get_contents(/sites/all/themes/MYTEMPLATE/lightGallery/dist/js/lightgallery.js):
failed to open stream: No such file or directory in _locale_parse_js_file()
 (line 1488 of /home/[MACHINE_NAME]/domains/[DOMAIN_URL]/public_html/includes/locale.inc).


The folder has permissions, it works perfectly, but the error message is persistent. I don't know why it happens and how to avoid it.
The problem was traced back to a call to drupal_add_js with relative URLs. I have added a prefix of drupal_get_path and the problem has disappeared for ever; it seems sometimes Drupal did not find the file because it thought it was in another location, but later it found it. This is why clearing the cache reproduced the problem. With the absolute path, problem is vanished.