diff options
| author | Markus Heiser <markus.heiser@darmarIT.de> | 2025-07-11 16:53:36 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-11 16:53:36 +0200 |
| commit | 574b285efa1658fd6d82d673e2063be659d5f624 (patch) | |
| tree | a617a27c4e89ab1abfd30434490aba01c21f34ee /searx/webapp.py | |
| parent | 9149175ff29afbba57fc899b1b555f70fa3b9d10 (diff) | |
[mod] remove option ui.static_use_hash (cache busting) (#5004)
Cache busting has caused serious problems for users in the past, here are two
examples:
- https://github.com/searxng/searxng/issues/4419
- https://github.com/searxng/searxng/issues/4481
And it makes development and deployment significantly more complex because it
binds the client side to the server side:
- https://github.com/searxng/searxng/pull/4466
In the light of a decoupled development of the WEB clients from the server side:
- https://github.com/searxng/searxng/pull/4988
is it appropriate to abandon this feature. In fact, it has been ineffective
since #4436 anyway.
However, the benefit has always been questionable, since at best only a few kB
of data are saved (at least in the context of an image_proxy, the effect is below
the detection limit). Ultimately, the client is responsible for caching.
Related: https://github.com/searxng/searxng/issues?q=label%3A%22clear%20browser%20cache%22
Closes: https://github.com/searxng/searxng/pull/4466
Closes: https://github.com/searxng/searxng/issues/1326
Closes: https://github.com/searxng/searxng/issues/964
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'searx/webapp.py')
| -rwxr-xr-x | searx/webapp.py | 53 |
1 files changed, 35 insertions, 18 deletions
diff --git a/searx/webapp.py b/searx/webapp.py index 15f79f151..cf7c58680 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -76,7 +76,6 @@ from searx.engines import ( from searx import webutils from searx.webutils import ( highlight_content, - get_static_files, get_result_templates, get_themes, exception_classname_to_text, @@ -131,7 +130,6 @@ warnings.simplefilter("always") # about static logger.debug('static directory is %s', settings['ui']['static_path']) -static_files = get_static_files(settings['ui']['static_path']) # about templates logger.debug('templates directory is %s', settings['ui']['templates_path']) @@ -239,25 +237,44 @@ def get_result_template(theme_name: str, template_name: str): return 'result_templates/' + template_name +_STATIC_FILES: list[str] = [] + + def custom_url_for(endpoint: str, **values): - suffix = "" - if endpoint == 'static' and values.get('filename'): - file_hash = static_files.get(values['filename']) - if not file_hash: + global _STATIC_FILES # pylint: disable=global-statement + if not _STATIC_FILES: + _STATIC_FILES = webutils.get_static_file_list() + + if endpoint == "static" and values.get("filename"): + + # We need to verify the "filename" argument: in the jinja templates + # there could be call like: + # url_for('static', filename='img/favicon.png') + # which should map to: + # static/themes/<theme_name>/img/favicon.png + + arg_filename = values["filename"] + if arg_filename not in _STATIC_FILES: # try file in the current theme - theme_name = sxng_request.preferences.get_value('theme') - filename_with_theme = "themes/{}/{}".format(theme_name, values['filename']) - file_hash = static_files.get(filename_with_theme) - if file_hash: - values['filename'] = filename_with_theme - if get_setting('ui.static_use_hash') and file_hash: - suffix = "?" + file_hash - if endpoint == 'info' and 'locale' not in values: - locale = sxng_request.preferences.get_value('locale') - if infopage.INFO_PAGES.get_page(values['pagename'], locale) is None: + theme_name = sxng_request.preferences.get_value("theme") + arg_filename = f"themes/{theme_name}/{arg_filename}" + if arg_filename in _STATIC_FILES: + values["filename"] = arg_filename + + if endpoint == "info" and "locale" not in values: + + # We need to verify the "locale" argument: in the jinja templates there + # could be call like: + # url_for('info', pagename='about') + # which should map to: + # info/<locale>/about + + locale = sxng_request.preferences.get_value("locale") + if infopage.INFO_PAGES.get_page(values["pagename"], locale) is None: locale = infopage.INFO_PAGES.locale_default - values['locale'] = locale - return url_for(endpoint, **values) + suffix + values["locale"] = locale + + return url_for(endpoint, **values) def image_proxify(url: str): |