Repository navigation
Keep the serve cache when a page is added or removed - #152
Merged
Merged
Conversation
The Markdown cache of `mkdocs serve` keyed every page on the whole list of site files, so adding, removing or renaming any page converted every page again. A page's conversion only uses the files that its links look up, so record those lookups and reuse the HTML while they find the same files. With 1,000 pages, a new page shows up after 2.2 s instead of 7.4 s with the mkdocs theme, and after 5.7 s instead of 10.9 s with Material.
Contributor
Merging this PR will improve performance by 23.4%
Performance Changes
Tip Curious why performance improved? Comment Comparing |
This was referenced Nov 2, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Markdown cache of
mkdocs serve(#131) keyed every page on the whole list of site files. So adding, removing or renaming any page made every page convert from Markdown again: 7–12 seconds on a 1,000-page site, compared with about 2 seconds for an edit.A page's conversion only uses the other files through the link lookups (
Files.get_file_from_path) in_RelativePathTreeprocessor, including the "Did you mean…" guesses. The cache now records those lookups and what each one found (the file's URL and inclusion). An entry is reused only while every lookup still finds the same thing. The page's own inclusion is now part of the key, because it changes warning levels.Serve rebuild times on a 1,000-page site (4 cores):
mkdocstheme, add a pagemkdocstheme, delete itI also checked the result on that site: after adding a page that an existing page already linked to, the serve output is the same as a clean build, except for the build date.
Related Issue
Follow-up to #131 and #145.
Checklist
dev-guide/plugins.mdnote on the cache)docs/about/release-notes.mdupdated (new "1.11.0 (unreleased)" section)