       ;; the live modification checker, but which haven't been rebuilt
       ;; yet (which would have removed them from the list).
       (dolist (local-repo straight--live-modified-repos)
-        (print local-repo (current-buffer))))))
+        (print local-repo (current-buffer))))
+    (unless (and straight--build-cache-text
+                 (string= (buffer-string) straight--build-cache-text))
+      (write-region nil nil (straight--build-cache-file) nil 0))))
 
 ;;;;; Live modification checking
 

  ;; malformed (or outdated), these values will be use.
  (setq straight--build-cache (make-hash-table :test #'equal))
  (setq straight--eagerly-checked-packages nil)
  (ignore-errors
    (with-temp-buffer
      ;; Using `insert-file-contents-literally' avoids

        ;; Otherwise, we can load from disk.
        (setq straight--build-cache cache)
        (setq straight--eagerly-checked-packages eager-packages)
        (setq straight--live-modified-repos live-repos)
        (setq straight--build-cache-text (buffer-string))))))

(defun straight--save-build-cache ()
  "Write data from memory into build-cache.el.
This uses the values of `straight--build-cache',
`straight--eagerly-checked-packages', and
`straight--live-modified-repos'."
  (with-temp-buffer
    ;; Prevent mangling of the form being printed in the case that
    ;; this function was called by an `eval-expression' invocation of
    ;; `straight-use-package'.
