README file from
GithubBacklink Cache
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.
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:
- Running the Backlink Cache: Open demo vault command.
- Downloading
backlink-cache-demo-vault-<version>.zip(<version>is the release version) from the Releases. - Browsing its source in
demo-vault/in this repository.
What it does
- A backlink index that keeps itself current, so the Backlinks pane and every plugin that asks for backlinks stop rescanning the vault. 01 Backlink cache
- Three ways to ask — fast from the cache, safe after pending changes settle, or the original built-in implementation for comparison. 02 Fast, safe, and original backlinks
- Canvas files are indexed too, and their links are exposed through
getCache(), which Obsidian leaves empty for canvases. 03 Canvas backlinks - Frontmatter markdown links count as backlinks when the
Frontmatter Markdown Linksplugin is installed. 03 Canvas backlinks - Refresh behavior is configurable. 04 Settings
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:
- Ensure you have the BRAT plugin installed and enabled.
- Click Install via BRAT.
- An Obsidian pop-up window should appear. In the window, click the
Add pluginbutton 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:
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
My other Obsidian resources
See my other Obsidian resources.