Gallery: Use cache
This commit is contained in:
parent
216a5c4da8
commit
52e358a48d
|
@ -481,11 +481,16 @@ class BServer:
|
||||||
def serveGallery(self, environ, start_response, lang):
|
def serveGallery(self, environ, start_response, lang):
|
||||||
_ = lang.gettext
|
_ = lang.gettext
|
||||||
lang_name = lang.info().get('language', None)
|
lang_name = lang.info().get('language', None)
|
||||||
|
|
||||||
|
start_response("200 OK", [('Content-type', "text/html; charset=utf-8")])
|
||||||
|
|
||||||
|
if ("Gallery", lang_name) in self._cache:
|
||||||
|
return self._cache[("Gallery", lang_name)]
|
||||||
|
|
||||||
langparam = ""
|
langparam = ""
|
||||||
if lang_name:
|
if lang_name:
|
||||||
langparam = "?language=" + lang_name
|
langparam = "?language=" + lang_name
|
||||||
|
|
||||||
start_response("200 OK", [('Content-type', "text/html; charset=utf-8")])
|
|
||||||
result = [f"""
|
result = [f"""
|
||||||
{self.genHTMLStart(lang)}
|
{self.genHTMLStart(lang)}
|
||||||
<head>
|
<head>
|
||||||
|
@ -528,7 +533,8 @@ class BServer:
|
||||||
</html>
|
</html>
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
return (s.encode("utf-8") for s in result)
|
self._cache[("Gallery", lang_name)] = [s.encode("utf-8") for s in result]
|
||||||
|
return self._cache[("Gallery", lang_name)]
|
||||||
|
|
||||||
def serve(self, environ, start_response):
|
def serve(self, environ, start_response):
|
||||||
# serve favicon from static for generated SVGs
|
# serve favicon from static for generated SVGs
|
||||||
|
|
Loading…
Reference in New Issue