Skip to content

Adds cache of pages when live reloading is enabled - #971

Closed
aeslaughter wants to merge 1 commit into
mkdocs:masterfrom
aeslaughter:cache-page
Closed

aeslaughter wants to merge 1 commit into
mkdocs:masterfrom
aeslaughter:cache-page

Conversation

@aeslaughter

Copy link
Copy Markdown
Contributor

Based on my past success trying to contribute enhancements, this probably won't go well 😄 , but I will try anyway.

This caches Page objects enabling livereload to much more efficient, which is nice when you have a large project.

This is in response to: https://groups.google.com/forum/#!topic/mkdocs/UaukffzOZMQ

@waylan

waylan commented Jun 22, 2016

Copy link
Copy Markdown
Contributor

This is interesting, but I do have a few questions/concerns. The build command already has the option to build --clean or not. In fact the default is not a clean build. In other words, the default build offers the same end result as this "cache" feature, albeit implemented in a different way. I realize that the serve command forces "clean" with no option to override. I guess it seems to me the way to get this behavior would be to just enable serve to disable forcing "clean".

Regardless, any time there is any change to any global template variables (including the nav), then all pages need to be rebuilt. For example, one page has its title changed. That title is displayed in the nav on every page, so every page needs to be rebuilt. So are we willing to forego consistency across pages for slightly quicker builds when using the dev server? I expect different people will give different answers to that question. I suppose leaving to the user to decide makes sense. Although, I think the default should stay as-is.

Still, I doubt we want to maintain 2 different code paths for accomplishing the same thing. If this gives us something better than not disabling --clean for the serve command, then maybe this should replace that feature/code. However, if there is no clear advantage, then just add a flag to the serve command to disable the clean argument passed to build.

@d0ugal

d0ugal commented Jun 23, 2016 •

Copy link
Copy Markdown
Contributor

@aeslaughter Did you intend to close this?

I support making MkDocs faster, that would be a great thing. I think generally it is fast enough for most users, but there will always be some larger projects that have trouble.

In other words, the default build offers the same end result as this "cache" feature, albeit implemented in a different way.

The default approach is the worst implementation of a cache, as it only caches stale artefacts. Every page is rebuild and overwrites the existing pages. So there is no speed boost. Honestly, the fact that --clean isn't the default is a bug and we should change that for 1.0 and perhaps add a new flag that means --dont-clean, but with a better name.

I would like to see a smarter cache be explored, perhaps there is a way we can cover enough of the edge cases to make it okay.

Ideally something like this would be best done as a plugin, then we can have as many opinionated caches as people like, but that is obviously tricky at the moment.

@waylan

waylan commented Jun 23, 2016

Copy link
Copy Markdown
Contributor

The default approach is the worst implementation of a cache

I suspected as much (never really dug into that part of the code). And that is why I added my last paragraph above. We may actually be able to use this with some modifications.

@aeslaughter

Copy link
Copy Markdown
Contributor Author

@d0ugal I did close this on purpose, it failed all sorts of tests. So, as I expected it is far more involved than what I need at the moment. It is something I may come back to in the future, but for now this works for my basic use case. It is also not a critical component to what I am trying to do.

As far as the use goes, I understand that all links and such will not be correct, but for what I (and those who will be using our tool) need this quick reload is useful. People will be writing snippets of markdown that explain physics equations (lots of latex math), these snippets are then automatically placed into a larger markdown file that contains auto generated syntax for a framework. It is really nice to have the markdown you are writing show up live, using the same parser as it will be deployed with, but waiting for all the pages to be created.

The purpose of all this is to have a single source documentation channel, where the markdown may be converted to a website (mkdocs), slides (Reveal.js), or pdf (to-be-determined).
Anyway, I will be rolling out a demo of my project soon, I will be sure to pass a link along so you all can see what type of crazy stuff I am doing with your tool. Which, by-the-way, is a very well written bit of code that I am enjoying working with.

@aeslaughter

Copy link
Copy Markdown
Contributor Author

On more comment, perhaps fixing up something similar to what I have here and calling it --develop or --quick would be useful, just be sure to include documentation regarding that all pages will not be correct.

@waylan

waylan commented Jul 14, 2016

Copy link
Copy Markdown
Contributor

For anyone following this discussion, it has been picked up and continued in the open issue at #990.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants