Upgrading to Drupal 11.4 and PHP 8.4 brings noticeable improvements in memory usage, JIT compilation, and security. However, two subtle mistakes in custom code or server configuration can ruin both your performance and your login flow in production.
1. The #1 Anonymous Cache Killer in Custom Controllers
If you embed a form or a Webform inside a custom controller using getForm() directly without proper render caching, Drupal may attach max-age = 0 or session contexts, forcing X-Drupal-Cache: UNCACHEABLE on your homepage. Instead, render webforms via their lazy render element:
return [
"#type" => "webform",
"#webform" => "contacto",
];
Combined with page_cache_maximum_age: 3600 in system.performance, your anonymous pages will immediately return X-Drupal-Cache: HIT and Cache-Control: max-age=3600, public.
2. Fixing "Redirects to external URLs are not allowed by default" on Subdirectory Rewrites
On hosts where public_html/.htaccess rewrites requests into Composer's web/index.php, PHP populates $_SERVER["SCRIPT_NAME"] = "/web/index.php". Drupal's DrupalKernel::initializeRequestGlobals() then sets $base_url with a /web suffix while URL generators emit root URLs, causing login redirects to fail with TrustedRedirectResponse errors. Normalizing SCRIPT_NAME and PHP_SELF at the top of web/index.php before autoload_runtime.php solves it permanently.