From 0a3eb24a0b7fb80533a8c9808b176678a5717ef8 Mon Sep 17 00:00:00 2001 From: bearz314 Date: Tue, 11 Feb 2025 00:48:27 +1100 Subject: [PATCH] [fix] limiter: prevent loading cached index html when redirected The redirection to index lets client requests CSS token, if somehow they haven't been. We need to ensure the html isn't cached so the latest token can be retrieved. --- searx/botdetection/ip_limit.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/searx/botdetection/ip_limit.py b/searx/botdetection/ip_limit.py index b4c6825b3..161a9826e 100644 --- a/searx/botdetection/ip_limit.py +++ b/searx/botdetection/ip_limit.py @@ -123,7 +123,9 @@ def filter_request( ) if c > SUSPICIOUS_IP_MAX: logger.error("BLOCK: too many request from %s in SUSPICIOUS_IP_WINDOW (redirect to /)", network) - return flask.redirect(flask.url_for('index'), code=302) + response = flask.redirect(flask.url_for('index'), code=302) + response.headers["Cache-Control"] = "no-store, max-age=0" + return response c = incr_sliding_window(redis_client, 'ip_limit.BURST_WINDOW' + network.compressed, BURST_WINDOW) if c > BURST_MAX_SUSPICIOUS: