Refresh Ninja cache files on regeneration.
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 44ff147..05b3034 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -567,6 +567,9 @@
         # fully created.
         os.replace(tempfilename, outfilename)
         mlog.cmd_ci_include(outfilename)  # For CI debugging
+        # Refresh Ninja's caches. https://github.com/ninja-build/ninja/pull/1685
+        if os.path.exists('.ninja_deps'):
+            subprocess.call(self.ninja_command + ['-t', 'restat'])
         self.generate_compdb()
 
     # http://clang.llvm.org/docs/JSONCompilationDatabase.html