-
Notifications
You must be signed in to change notification settings - Fork 35
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
Add caching to wiki entries and homepage #59
Conversation
6fc5243
to
61b6e0e
Compare
Hi @kura This is exactly how I planned on implementing it myself. Thanks! I'll test it first before merging it. I currently don't have my PC with me so I'll do it asap. |
Cool, no worries. It's also currently being tested on my home lab wiki. |
Hi @kura |
Yeah it's a lot faster with a little caching. :D I chose When you say |
Alright I think we can leave it then. I meant inside the cloned repo. |
Yeah that would work. I'll update the default. |
05f7f78
to
3238825
Compare
I was digging in to why one of the tests was failing on GitHub Actions and found it's because of an interesting issue with using I tried changing the cache path to I'm going to change back to using [2022-09-04 14:28:26,839] INFO in git_manager: Initializing existing repo >>> /wiki ...
Traceback (most recent call last):
File "/app/wikmd/wiki.py", line 50, in <module>
cache = Cache(cfg.cache_dir)
File "/app/wikmd/cache.py", line 12, in __init__
os.makedirs(path)
File "/usr/lib/python3.6/os.py", line 210, in makedirs
makedirs(head, mode, exist_ok)
File "/usr/lib/python3.6/os.py", line 220, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '.cache' |
9973072
to
fbb4654
Compare
Alright perfect! Didn't know that! |
Summary
Add caching to wiki entries and the homepage when they're first viewed.
Details
The way this caching works is really simple; when an entry is first viewed the HTML generated will be stored in a local cache. Each time the entry is viewed again, the HTML will be served from the cache, unless the source file has been modified since the cache was generated.
If the source file is newer than the cached HTML, the cache file will be deleted and the new content generated and cached.
This caching system could also be used to cache other thing, it'd be possible to reconfigure it further if required too, like moving the file modification time check done in
cache.get
, allowing caching things that do not have a physical file on disk but this would require moving the modification check to where the entry is read and returned to the user for example.Checks
docs/<corresponding file>