From time to time, the system does not find a file that exists
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.