Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search: caching for faster startup #5391

Open
4 tasks done
nnmm opened this issue Apr 19, 2023 · 4 comments
Open
4 tasks done

Search: caching for faster startup #5391

nnmm opened this issue Apr 19, 2023 · 4 comments
Labels
change request Issue requests a new feature or improvement

Comments

@nnmm
Copy link

nnmm commented Apr 19, 2023

Context

In our docs, it takes about 5 seconds for the search plugin to become ready.

Description

Currently, the search index input is requested and indexed on every page load. Instead, the final search index could be kept in local browser storage and loaded from there if the search index input can be determined to be the same.

Related links

Use Cases

The user would need to provide a version identifier (e.g. git SHA, release number) that will be used as the cache key. Alternatively, material could compute a hash of the docs itself, though I'm not sure how realistic that is.

The advantages would be reduced bandwidth usage and less delay until the search plugin is ready.

Visuals

No response

Before submitting

@squidfunk
Copy link
Owner

Thanks for suggesting! We're currently reworking the search implementation to be much more powerful that what we currently have in place. Caching is something we'll also be investigating. In the meantime, you can use instant loading, which means you will only pay the cost of index initialization on the first request.

@squidfunk squidfunk added the change request Issue requests a new feature or improvement label Apr 19, 2023
@infotexture
Copy link

If I understand #2976 correctly, the prebuilt search index will be removed in the next iteration of the search functionality.

One of the strengths of Material for MkDocs thus far has been its support for offline usage.

Will the caching mechanism proposed here (or the instant loading workaround) support the offline use case with the new search features?

@squidfunk
Copy link
Owner

The prebuilt index was removed in Material for MkDocs 8 1,5 years ago. Offline search already works pretty well, and the new search will definitely continue to do so. We'll investigate caching on file:// locations, but I think for most docs, it won't be necessary, as the new search needs a fraction of the time to create the search index. My tests show that the new search index builds up to 5x faster, i.e., for our docs, the time dropped from 200ms to 40ms.

Instant loading does not work on file:// due to browser limitations. Same goes for some other features.

@squidfunk squidfunk changed the title Search index caching Search: caching for faster startup Aug 10, 2023
@squidfunk
Copy link
Owner

Please see the announcement in #6307.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
change request Issue requests a new feature or improvement
Projects
None yet
Development

No branches or pull requests

3 participants