Repository navigation
Reuse Markdown conversions between serve rebuilds - #131
Merged
Merged
Conversation
Contributor
Merging this PR will not alter performance
Performance Changes
Comparing |
Every rebuild of mkdocs serve converted every page from Markdown to HTML again, although usually only one file changed. Keep the converted HTML, table of contents, anchors and logged warnings of each page while the server runs, and reuse them when the page's Markdown (after on_page_markdown), the extensions and their config, the page URL and the site's files are unchanged. Warnings are logged again, so strict mode and the console behave as before. Plugin events still run for every page. The cache is only used when every Markdown extension is on a list of extensions known to depend on nothing else; snippets, b64 and extensions that plugins add as instances (mkdocstrings, autorefs) turn it off. 400 pages with Material: rebuild 7.6s -> 4.0s.
shenxianpeng
force-pushed
the
claude/project-thread-8gce4u
branch
from
November 1, 2026 13:10
b156939 to
eb816e0
Compare
This was referenced Nov 1, 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.
Every rebuild of
mkdocs serveconverts every page from Markdown to HTML again, although usually only one file changed. Markdown conversion is about a third of a rebuild.While the server runs, this keeps each page's converted HTML, table of contents, title, anchors and logged warnings, keyed by:
on_page_markdown,use_directory_urlsand thevalidationsettings,When all of these match, the earlier result is reused and its warnings are logged again, so strict mode and the console output stay the same. All plugin events still run for every page, with the same values. Entries a rebuild didn't use are dropped at the next rebuild.
The cache is only used when every extension is on a list of extensions whose output depends only on their input: Python-Markdown's own and most of PyMdown Extensions, plus Material's emoji.
pymdownx.snippetsandpymdownx.b64read other files and are left out. Extensions that plugins add as instances (mkdocstrings, mkdocs-autorefs, which record anchors while converting) turn it off, so those sites rebuild exactly as before.mkdocs builddoesn't use the cache.Numbers
Real
mkdocs serve, 400-page benchmark corpus with Material for MkDocs, edit one page: rebuild 7.6s → 4.0s. With themkdocstheme, in-process rebuild 4.9s → 2.2s. A newtest_serve_rebuildCodSpeed benchmark covers this loop.Checks
mkdocs serve: the edit shows up after the rebuild.Release notes under 1.11.0 and a note for plugin authors in the plugin guide.
Checklist
docs/about/release-notes.mdupdated (if applicable)