Fix download button waiting if document has started but not completed downloading

Fixes #1826

The "download from cache" feature works like a charm but is currently triggered when a document *starts* downloading/displaying. (A plain "download from URL" is used when the document has not even started that). This commit keeps track of a document's download completion status and falls back to "download from URL" if it is not in the cache, making the download button consistently responsive.