11-18 2018

The OneNote Cache and Offline Notes

Why is it possible to edit OneNote notebooks in the cloud without an active Internet connection? Does this mean that there are local notebooks in all versions of OneNote? Yes and No. Learn some basics about the cache and editing notes offline.

As you probably already know, OneNote lets you read and edit notes without an active internet connection, as long as the notebook has been opened before, when you had a connection. This gets often confused with locally stored notebooks being held on every OneNote client and platform. In fact, there is a sort of local copy, but it’s very different from a duplicate of the notebook files on OneDrive or OneDrive for Business. Let me explain.

OneNote’s file handling is very different from Word, Excel or other Windows programs, which explains some peculiarities. If the following appears too detailed for you, simply jump down to the “Summary” section at the end of the article.

OneNote’s special file handling

Most users assume, that OneNote acts like every other windows program: load a data file (a document or notebook in this case) from a storage device (hard drive, cloud storage…) to the computers or mobile device’s RAM, where you edit its content and then save it back to the storage location, overwriting the previous version. But this is not what OneNote does. This is what happens instead:

At first OneNote actually does load the note data from the disk or from the cloud (I won’t discuss the exact file format in this article as that’s not relevant here). This always happens when you open a notebook that hasn’t been opened before and as such has not been listed in the notebook navigation.

But instead of holding the note data in RAM memory to let you modify it, something else is happening right after the loading / downloading: OneNote immediately converts this data into a different and very special binary format. Simply put, all objects contained in the note pages (images, files, text paragraphs…) are stored as individual files or records in a hidden location on the local device (e.g. the PC hard disk or the internal smartphone or tablet flash memory). This highly fragmented copy of the data is the so-called notebook cache. It’s not only stored to the device but also replaces the previously loaded notebook files in RAM. The actual notebook files on OneDrive or your computer (OneNote Win 32 for Windows only) remain untouched; all editing is done in the cache version in memory only and every change automatically saved to the cache data files (but not to the actual notebook yet).

That’s the reason why no active internet connection is needed at this point. As long as there is that locally stored cache version (again: not to be confused with a local copy of the actual notebook files, because the cache is in a completely different format), you can completely work offline even if the actual notebook files are stored on OneDrive. You can edit, add and delete notes, whole pages, even sections. What you can’t do is create new notebooks in the cloud. This needs to be done at the original storage location first, before a local cache copy is created. Also you can’t open notebooks from OneDrive while offline, of course.

Although it’s rather easy to find and access the OneNote cache files at least in OneNote 2010/2013/2016 for Windows, this is of not much use. Those files are in a special, fragmented binary format that can’t be used as a backup.

In order to update the “real” notebook files, an internal OneNote synchronization mechanism compares the changes from the cache files with the actual notebook files. Of course, if the notebooks are in the cloud, this only happens when an Internet connection is (re)established. Well, thinking of it, I might have been wrong here. Because after editing anything in your notes OneNote tries to start a synchronization even when offline, this must work a bit different. OneNote obviously knows that a sync is needed without being able to compare the note content to the cloud files. I assume, every edit sets a flag in the cache files so the sync mechanism knows that changes might have occured and an update is needed. Or something similar 🙂
Interesting fact: The same mechanism including the separation of cache and notebook files also applies to notebooks that are stored locally or a network folder, which is only possible with the “full” Windows-Office-version of OneNote.

I have tried to illustrate the process in the image at the beginning of the article.

It should also correct a common misunderstanding that OneNote clients (like OneNote for iPhone, Android, Web, Windows, Mac) are syncing notebooks to each other. They don’t. Each OneNote synchronizes it’s own local cache files against the files on OneDrive. So those are the “reference version” that all OneNote clients need to access to be up to date.

The sync mechanism is based on a special protocol called COBALT or MS-FSSHTTP which is related to the protocol that is used by Sharepoint. It is built into the OneNote client and does not make use of the local OneDrive app on your device. In fact, it would perfectly work, if OneDrive wasn’t installed on your computer or mobile device at all. Yes, you can see a representation of OneNote notebooks in your local OneDrive sync folder. But they are only placeholders (links to the actual notebooks on OneDrive). They do not contain any notebook data nor are they part of the sync process.

Other file cloud services such as Dropbox, Google Drive or Box do not support COBALT, so OneNote notebooks cannot be synchronized with these services (although that seems to work by placing locally stored notebooks in the Dropbox- or Google-Drive-sync-folder). More about this in this older but still valid article.

Because the sync mechanism is part of OneNote and not of the operating system (e.g. as a service in Windows), notebooks are only synchronized while OneNote is running.

Why so cumbersome?

But why can’t OneNote handle notebook files just as easily (load, edit, save) as Word or other Windows programs?

There are mainly two reasons for this:

The first is the (temporary) offline availability of notebooks. To be able to edit your notebooks stored in the cloud (or on a LAN server) even without any network connection, you need a full copy on the local device. That’s why OneNote, after opening a notebook, immediately mirrors its contents locally. That method is the reason why large notebooks can take quite long to open; its complete content has to be downloaded first. Once downloaded, you can quickly navigate through all notes, because the local cache is used. If OneNote would download only currently accessed content, navigating through pages and sections would be a pain, because everything would get downloaded on demand. Also, offline work would be impossible.

The second reason has to do with the option to concurrently edit notes from different devices or by several users. Conventional PC file systems simply do not allow this. Once an application has opened a data file, that file gets locked for editing by other applications or computers. Some applications refuse to open a locked file, while others (Excel for example) at least allow read-only access. The file locking is only removed by saving and closing the file from the editing application. This mechanism is part of the operating system; no application, including OneNote, is able to avoid it. But because in OneNote every user / device has it’s own local cache copy, file locking is not a concern.

As I mentioned before, the files in the local OneNote cache are much more fragmented than the original copy. It consists of many, many small files. There is a reason for this too:

In OneNote, several users can edit not only the same notebook at a time but also the same section or even page. This is possible because every object (text paragraph, image, printout, embedded file…) on a note page is stored in a separate cache file. On the server side (e.g. on OneDrive) a similar fragmentation takes place. So only changed objects (cache files) are transferred during synchronization. The server is reconstructing the page by collecting those fragments and putting them together like pieces of a puzzle. It does not matter if those puzzle pieces are provided by different devices or users.

So while concurrent edits of the same page are possible because of this system, there is also a restriction: If two or more users (or you on different devices) edit the same object, this mechanism will fail. The object (e.g. a text paragraph) is the smallest individual unit. So when two versions of the same object (puzzle piece) arrive at the server, OneNote cannot solve the conflict. In this case, the synchronization service helps itself by creating a copy of the affected page. It also warns the user that there is a conflict that cannot be resolved. It leaves the task to manually merge the edits (or choose the correct version) to the user.

The biggest advantage of the protocol and the fragmentation technique, apart from teamwork or multi-device use: Only changed objects are transmitted over the network which means speed, lower use of bandwidth and data contingent.

Can the cache be used as a backup or offline notebook?

So obviously a local copy of every opened notebook does exist. Can this be used as a notebook backup to store it away on an external disk or thumb drive? Sorry, but the answer is No. Even if you were able to locate and access the cache files (which can be only be done on OneNote 2010/2013/2016 for Windows without serious hacking) and copy it away, that data is of no use. It could not be restored at a later time, because there are still some additional indexes and registry entries in play. It just won’t work.

And what about (mis)using the locally cached data as an offline-only notebook? Generally, this is possible but I would not recommend it. Yes, you could create an empty notebook on OneDrive (at least for this a cloud connection is needed), sync it to your device and thus create a local cache copy. Then you could delete the notebook from OneDrive and just keep it open on your device to just work with the cache copy. The content will never get synced to OneDrive because the target notebook does not even exist. You’d get constant sync error messages instead which you could ignore.

But this is a dangerous game: The local cache is somewhat fragile. It can easily be erased once and for all by resetting the app, maybe during a future update of the app or even just by closing the notebook. I would not recommend it.

Summary (tl;dr)

The above information in a nutshell:

  • When opening a notebook, OneNote loads the corresponding files from the disk or from the cloud, but does not work with them directly, as Word or other programs do.
  • Instead, it immediately creates a copy of all content on the local device, called the cache. This also applies to smartphones or tablets.
  • The cache copy is in a completely different format than the original files. All notes are fragmented into small portions. Each “fragment” represents an object, such as a paragraph of text or an image.
  • These cache files are not usable, for example as a notebook backup. They are also rather fragile.
  • OneNote will work exclusively with this cache copy; all changes are made here, not to the actual notebook files.
  • An independent sync mechanism on the client (integrated in OneNote) and server (e.g. OneDrive) collects changed and uploaded cache fragments to create updated notebook files. This can be done from multiple devices or users at the same time.

Check Also

Upcoming features to OneNote for Windows 10

OneNote Principal Product Manager Benjamin Hodes presented some upcoming features of the Windows 10 app …

2 comments

  1. “What you can’t do is create new notebooks in the cloud”…
    As for October 2018, this is not true… You can create Notebooks online (and you have already been able to create notebooks from within your One Drive for a long time…)

    Thanks for this Blog post as it clearly states that Chris Pratley and his team have been genius’ with their invention !
    And I am really looking forward to the new sync engine that makes real-time collaboration possible…

    • Stefan Wischner

      You clearly misunderstood me (may be because of my lousy English :)). i was explaining what you can and can’t do while your device is offline. I doubt you could create a notebook using the web browser on OneDrive while not connected to the internet 🙂

Leave a comment

%d bloggers like this: