fix(redirect): add no-cache headers to prevent browser caching of redirects

- Implemented `send_no_cache_headers()` in the redirect function to ensure that browsers do not cache redirect responses, adhering to best practices for HTTP redirects.
This commit is contained in:
Yury Pikhtarev 2025-06-20 15:06:08 +04:00
commit de33898b73
No known key found for this signature in database

View file

@ -1437,6 +1437,9 @@ function redirect($url)
$redirect_url = $server_protocol . $server_name . $server_port . $script_name . preg_replace('#^\/?(.*?)\/?$#', '/\1', $url); $redirect_url = $server_protocol . $server_name . $server_port . $script_name . preg_replace('#^\/?(.*?)\/?$#', '/\1', $url);
// Send no-cache headers to prevent browsers from caching redirects
send_no_cache_headers();
// Behave as per HTTP/1.1 spec for others // Behave as per HTTP/1.1 spec for others
header('Location: ' . $redirect_url, response_code: 301); header('Location: ' . $redirect_url, response_code: 301);
exit; exit;