这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@return42
Copy link
Member

@return42 return42 commented Mar 6, 2025

As long we don't have a working solution for cache busting [3][4] we should not set an expire time in the uWSGI config.

If we have changes to the CSS or JS files, these are not yet transported to the client by default, which causes problems and irritations on the client side [3]:

The default procedure in every web browser is the "304 Not Modified" [2] and this default procedure should also be sufficient for us as long as we have not implemented a complete alternative (cache busting) / form [1]

By default uWSGI will add a Last-Modified [2] header to all static responses,
and will honor the If-Modified-Since [2] request header.

As long we don't have a working solution for cache busting [3][4] we should not
set an expire time in thw uWSGI config.

The default procedure in every web browser is the "304 Not Modified" [2] and
this default procedure should also be sufficient for us as long as we have not
implemented a complete alternative (cache busting) / form [1]

> By default uWSGI will add a Last-Modified [2] header to all static responses,
> and will honor the If-Modified-Since [2] request header.

[1] https://uwsgi-docs.readthedocs.io/en/latest/StaticFiles.html#setting-the-expires-headers
[2] https://developer.mozilla.org/de/docs/Web/HTTP/Status/304
[3] searxng#4433
[4] searxng#964

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
@dalf
Copy link
Contributor

dalf commented Mar 6, 2025

Please wait before merging this PR, some context is required.

@dalf
Copy link
Contributor

dalf commented Mar 6, 2025

As far I remember, I might be wrong

With the docker image

The static files are served by UWSGI.
UWSGI ignores the query parameter so https://searx.example.com/static/simple/logo.svg?gijreghiregjioergjeriogrjio reads the file /static/simple/logo.svg.

==>

static-expires = /* 86400

and

https://github.com/searxng/searxng-docker/blob/4aa1d1487869d13160a5bf14c79eaf95d28def15/searxng/settings.yml#L9

works together to provide a nice speed boost.

No docker, no configuration about the static file

In this scenario, there is a reverse proxy but the static files are served the Flask application.

In this case https://searx.example.com/static/simple/logo.svg?gijreghiregjioergjeriogrjio does not work.

Markus, you may think ok this is not the standard installation, so this is not supported. However, I think a lot of existing installations are configured this way (static files served by the Flask application).

Perhaps it is possible to "fix" the Flask application, but I'm not sure this is right way. The recommended way I see is URL like this https://searx.example.com/static/simple/logo.gijreghiregjioergjeriogrjio.svg.

@return42
Copy link
Member Author

return42 commented Mar 7, 2025

UWSGI ignores the query parameter so https://searx.example.com/static/simple/logo.svg?gijreghiregjioergjeriogrjio reads the file /static/simple/logo.svg.

Sure? .. As far I remember the ? issue was related to the (nginx) proxy .. if I understand your comment correctly:

However .. as long we set:

static-expires = /* 86400

in our installation methods, we have a bug when ui.static_use_hash is set to false (what the default in SearXNG core is) .. this is what I mean by:

As long we don't have a working solution for cache busting [3][4] we should not set an expire time in the uWSGI config.

I fully agree with ..

The recommended way I see is URL like this https://searx.example.com/static/simple/logo.gijreghiregjioergjeriogrjio.svg.

If we have fixed the URL, then we can activate ui.static_use_hash: true by default and we can set static-expires = /* 86400 in our uWSGI installation methods.

But before it isn't fixed and cache busting is not the default we should not set static-expires in uWSGI .. otherwise we will see issue reports like these from the last days:

works together to provide a nice speed boost.

This PR is just a interim solution to get static files updated on our clients, which is currently not the case on some installations that using the SearXNG defaults from searx/settings.yml and this uWSGI setup .. which is also used by the installation scripts.

@return42
Copy link
Member Author

return42 commented Mar 8, 2025

I merge this PR / it gives us time to look for:

@return42 return42 merged commit 523d2a7 into searxng:master Mar 8, 2025
9 checks passed
@return42 return42 deleted the uwsgi-static-expire branch March 8, 2025 08:08
return42 added a commit to return42/searxng that referenced this pull request Jul 11, 2025
Cache busting has caused serious problems for users in the past, here are two
examples:

- searxng#4419
- searxng#4481

And it makes development and deployment significantly more complex because it
binds the client side to the server side:

- searxng#4466

In the light of a decoupled development of the WEB clients from the server side:

- searxng#4988

is it appropriate to abandon this feature. In fact,  it has been ineffective
since searxng#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: searxng#4466
Closes: searxng#1326
Closes: searxng#964

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
return42 added a commit that referenced this pull request Jul 11, 2025
Cache busting has caused serious problems for users in the past, here are two
examples:

- #4419
- #4481

And it makes development and deployment significantly more complex because it
binds the client side to the server side:

- #4466

In the light of a decoupled development of the WEB clients from the server side:

- #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: #4466
Closes: #1326
Closes: #964

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants