Backlink Cache

approved

by Michael Naumov

Store backlink cache to speed up `app.metadataCache.getBacklinksForFile`.

53 stars31,564 downloadsUpdated 19d agoMIT

Backlink Cache

Buy Me a Coffee GitHub release GitHub downloads Coverage: 100%

Asking Obsidian which notes link to this one means scanning every note in the vault. On a large vault that is slow enough to be felt — the Backlinks pane lags, and every plugin that needs backlinks pays the same cost, repeatedly.

This plugin keeps a backlink index and answers from it instead. The Backlinks pane gets faster, and so does anything else that asks. On a small vault you will not notice; that is the point at which you do not need it.

All 120 backlinks, in a vault of thousands

More screenshots
From an index, not a scan of every note Same answer as Obsidian, arrived at faster Every backlink of this note, in one list From an index, not a scan of every note Same answer as Obsidian, arrived at faster

Demo vault

The documentation is an interactive demo vault. Every feature has a note that explains what it does and why you would want it, with buttons that measure the difference for real.

Start reading here — it is plain markdown, so it works on GitHub with nothing installed.

A copy of the vault ships with every release. You can access it via any of the following:

  1. Running the Backlink Cache: Open demo vault command.
  2. Downloading backlink-cache-demo-vault.zip from the Releases. It unzips into a single backlink-cache-demo-vault-<version> folder.
  3. Browsing its source in demo-vault/ in this repository.

What it does

For plugin developers

This plugin replaces app.metadataCache.getBacklinksForFile() with a faster implementation, adds an overload accepting a vault path as well as a TFile, and keeps the original reachable:

const fast = app.metadataCache.getBacklinksForFile(pathOrFile);
const safe = await app.metadataCache.getBacklinksForFile.safe(pathOrFile);
const original = app.metadataCache.getBacklinksForFile.originalFn(file);

To use the updated signatures from your own plugin, copy types.d.ts into your code. 02 Fast, safe, and original backlinks runs all three side by side.

Installation

The plugin is available in the official Community Plugins repository.

Beta versions

To install the latest beta release of this plugin (regardless if it is available in the official Community Plugins repository or not), follow these steps:

  1. Ensure you have the BRAT plugin installed and enabled.
  2. Click Install via BRAT.
  3. An Obsidian pop-up window should appear. In the window, click the Add plugin button once and wait a few seconds for the plugin to install.

Debugging

By default, debug messages for this plugin are hidden.

To show them, run the following command in the DevTools Console:

window.DEBUG.enable('backlink-cache');

For more details, refer to the documentation.

Changelog

All notable changes to this project will be documented in the CHANGELOG.

Contributing

Contributions are welcome — see CONTRIBUTING to get set up.

Support

Buy Me A Coffee

My other Obsidian resources

See my other Obsidian resources.

License

© Michael Naumov

For plugin developers

Search results and similarity scores are powered by semantic analysis of your plugin's README. If your plugin isn't appearing for searches you'd expect, try updating your README to clearly describe your plugin's purpose, features, and use cases.