Skip to content

Commit 7101592

Browse files
authored
Fix: only try to load a cache file from disk if the file exists (#84)
This could happen if the first time a page was loaded, was done by someone who was logged in. This does update LAST_TIME_RENDERED for browser if-modified-since caching, but does not write the file to disk. If a non-logged-in user visit the page after, the page is not on disk.
1 parent 99a63de commit 7101592

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

truewiki/views/page.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def view(user, page: str, if_modified_since) -> web.Response:
7373
# We already rendered this page before. If the browser has it in his
7474
# cache, he can simply reuse that if we haven't rendered since.
7575
response = web.HTTPNotModified()
76-
elif not user and cache_filename:
76+
elif not user and cache_filename and os.path.exists(cache_filename):
7777
# We already rendered this page to disk. Serve from there.
7878
with open(cache_filename) as fp:
7979
body = fp.read()

0 commit comments

Comments
 (0)