diff options
author | Alexandre Flament <alex@al-f.net> | 2020-10-03 15:02:44 +0200 |
---|---|---|
committer | Alexandre FLAMENT <alexandre.flament@hesge.ch> | 2022-03-05 10:50:48 +0000 |
commit | 1c7d8815fb54dd37ed6765560c223cb93976b6f4 (patch) | |
tree | 14cdc2f8f9f7988d0026a92eab9098774db5b578 /searx/webapp.py | |
parent | 927aa71133839ce5713b742b43285953301adf36 (diff) | |
download | searxng-1c7d8815fb54dd37ed6765560c223cb93976b6f4.tar.gz searxng-1c7d8815fb54dd37ed6765560c223cb93976b6f4.zip |
[mod] URL for the static file contains the sha1
* allow to cache the static file forever
* avoid bugs when the static files are updated but not reloaded
Diffstat (limited to 'searx/webapp.py')
-rwxr-xr-x | searx/webapp.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/searx/webapp.py b/searx/webapp.py index df717a7b1..999b4f64b 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -16,7 +16,7 @@ from timeit import default_timer from html import escape from io import StringIO import typing -from typing import List, Dict, Iterable +from typing import List, Dict, Iterable, Optional import urllib import urllib.parse @@ -348,7 +348,7 @@ def code_highlighter(codelines, language=None): return html_code -def get_current_theme_name(override: str = None) -> str: +def get_current_theme_name(override: Optional[str] = None) -> str: """Returns theme name. Checks in this order: @@ -373,14 +373,16 @@ def get_result_template(theme_name: str, template_name: str): return 'result_templates/' + template_name -def url_for_theme(endpoint: str, override_theme: str = None, **values): +def url_for_theme(endpoint: str, override_theme: Optional[str] = None, **values): + suffix = "" if endpoint == 'static' and values.get('filename'): theme_name = get_current_theme_name(override=override_theme) filename_with_theme = "themes/{}/{}".format(theme_name, values['filename']) - if filename_with_theme in static_files: + file_hash = static_files.get(filename_with_theme) + if file_hash: values['filename'] = filename_with_theme - url = url_for(endpoint, **values) - return url + suffix = "?" + file_hash + return url_for(endpoint, **values) + suffix def proxify(url: str): |