WordPress / WordPress/performance

Image Prioritizer causes 502 Bad Gateway due to oversized Link response headers (Nginx reverse proxy)

Open
#2,304 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

[Plugin] Image Prioritizer [Type] Bug
Dominant language
PHP
Stars
461
Forks
165
Avg merge
11h 12m
Merged PRs (30d)
28

Description

Bug Description

The Image Prioritizer module in the Performance Lab plugin can generate extremely large HTTP Link: rel=preload; as=image response headers on uncached pages (e.g. when users are logged in).

When pages contain responsive images (srcset, sizes) with long or non-ASCII filenames (e.g. UTF-8 / URL-encoded filenames), the resulting response headers may exceed common reverse-proxy limits (such as Nginx proxy buffer limits).

When this occurs, Nginx logs:

  • upstream sent too big header while reading response header from upstream

And Apache may log:

  • AH01068: Got bogus version

This results in intermittent HTTP 502 Bad Gateway errors for logged-in users.

Full Response Headers (example with UTF-8 / URL-encoded filename)

cache-control: no-cache, must-revalidate, max-age=0, no-store, private
content-encoding: br
content-type: text/html; charset=UTF-8
date: Wed, 17 Dec 2025 13:48:35 GMT
expires: Wed, 11 Jan 1984 05:00:00 GMT
link: <https://www.example.com/wp-content/uploads/2025/12/favicon.png>; rel="preload"; fetchpriority="high"; as="image"; imagesrcset="https://www.example.com/wp-content/uploads/2025/12/favicon.png 1024w, https://www.example.com/wp-content/uploads/2025/12/favicon-300x300.png 300w, https://www.example.com/wp-content/uploads/2025/12/favicon-150x150.png 150w, https://www.example.com/wp-content/uploads/2025/12/favicon-768x768.png 768w"; imagesizes="(width <= 480px) 48px, (600px < width <= 782px) 48px, (782px < width) 48px, (max-width: 48px) 100vw, 48px"; media="screen and (600px < width <= 782px)", <https://www.example.com/wp-content/uploads/2025/12/%E0%B8%9B%E0%B8%A3%E0%B8%B0%E0%B8%81%E0%B8%B2%E0%B8%A8%E0%B8%AA%E0%B8%96%E0%B8%B2%E0%B8%9B%E0%B8%99%E0%B8%B2%E0%B8%AA%E0%B8%A1%E0%B9%80%E0%B8%94%E0%B9%87%E0%B8%88%E0%B8%9E%E0%B8%A3%E0%B8%B0%E0%B9%80%E0%B8%88%E0%B9%89%E0%B8%B2%E0%B8%9A%E0%B8%A3%E0%B8%A1%E0%B9%80%E0%B8%98%E0%B8%AD-%E0%B9%80%E0%B8%88%E0%B9%89%E0%B8%B2%E0%B8%9F%E0%B9%89%E0%B8%B2%E0%B8%81_Page_2.png>; rel="preload"; fetchpriority="high"; as="image"; imagesrcset="https://www.example.com/wp-content/uploads/2025/12/%E0%B8%9B%E0%B8%A3%E0%B8%B0%E0%B8%81%E0%B8%B2%E0%B8%A8%E0%B8%AA%E0%B8%96%E0%B8%B2%E0%B8%9B%E0%B8%99%E0%B8%B2%E0%B8%AA%E0%B8%A1%E0%B9%80%E0%B8%94%E0%B9%87%E0%B8%88%E0%B8%9E%E0%B8%A3%E0%B8%B0%E0%B9%80%E0%B8%88%E0%B9%89%E0%B8%B2%E0%B8%9A%E0%B8%A3%E0%B8%A1%E0%B9%80%E0%B8%98%E0%B8%AD-%E0%B9%80%E0%B8%88%E0%B9%89%E0%B8%B2%E0%B8%9F%E0%B9%89%E0%B8%B2%E0%B8%81_Page_2.png 1654w, https://www.example.com/wp-content/uploads/2025/12/%E0%B8%9B%E0%B8%A3%E0%B8%B0%E0%B8%81%E0%B8%B2%E0%B8%A8%E0%B8%AA%E0%B8%96%E0%B8%B2%E0%B8%9B%E0%B8%99%E0%B8%B2%E0%B8%AA%E0%B8%A1%E0%B9%80%E0%B8%94%E0%B9%87%E0%B8%88%E0%B8%9E%E0%B8%A3%E0%B8%B0%E0%B9%80%E0%B8%88%E0%B9%89%E0%B8%B2%E0%B8%9A%E0%B8%A3%E0%B8%A1%E0%B9%80%E0%B8%98%E0%B8%AD-%E0%B9%80%E0%B8%88%E0%B9%89%E0%B8%B2%E0%B8%9F%E0%B9%89%E0%B8%B2%E0%B8%81_Page_2-212x300.png 212w, https://www.example.com/wp-content/uploads/2025/12/%E0%B8%9B%E0%B8%A3%E0%B8%B0%E0%B8%81%E0%B8%B2%E0%B8%A8%E0%B8%AA%E0%B8%96%E0%B8%B2%E0%B8%9B%E0%B8%99%E0%B8%B2%E0%B8%AA%E0%B8%A1%E0%B9%80%E0%B8%94%E0%B9%87%E0%B8%88%E0%B8%9E%E0%B8%A3%E0%B8%B0%E0%B9%80%E0%B8%88%E0%B9%89%E0%B8%B2%E0%B8%9A%E0%B8%A3%E0%B8%A1%E0%B9%80%E0%B8%98%E0%B8%AD-%E0%B9%80%E0%B8%88%E0%B9%89%E0%B8%B2%E0%B8%9F%E0%B9%89%E0%B8%B2%E0%B8%81_Page_2-724x1024.png 724w, https://www.example.com/wp-content/uploads/2025/12/%E0%B8%9B%E0%B8%A3%E0%B8%B0%E0%B8%81%E0%B8%B2%E0%B8%A8%E0%B8%AA%E0%B8%96%E0%B8%B2%E0%B8%9B%E0%B8%99%E0%B8%B2%E0%B8%AA%E0%B8%A1%E0%B9%80%E0%B8%94%E0%B9%87%E0%B8%88%E0%B8%9E%E0%B8%A3%E0%B8%B0%E0%B9%80%E0%B8%88%E0%B9%89%E0%B8%B2%E0%B8%9A%E0%B8%A3%E0%B8%A1%E0%B9%80%E0%B8%98%E0%B8%AD-%E0%B9%80%E0%B8%88%E0%B9%89%E0%B8%B2%E0%B8%9F%E0%B9%89%E0%B8%B2%E0%B8%81_Page_2-768x1086.png 768w, https://www.example.com/wp-content/uploads/2025/12/%E0%B8%9B%E0%B8%A3%E0%B8%B0%E0%B8%81%E0%B8%B2%E0%B8%A8%E0%B8%AA%E0%B8%96%E0%B8%B2%E0%B8%9B%E0%B8%99%E0%B8%B2%E0%B8%AA%E0%B8%A1%E0%B9%80%E0%B8%94%E0%B9%87%E0%B8%88%E0%B8%9E%E0%B8%A3%E0%B8%B0%E0%B9%80%E0%B8%88%E0%B9%89%E0%B8%B2%E0%B8%9A%E0%B8%A3%E0%B8%A1%E0%B9%80%E0%B8%98%E0%B8%AD-%E0%B9%80%E0%B8%88%E0%B9%89%E0%B8%B2%E0%B8%9F%E0%B9%89%E0%B8%B2%E0%B8%81_Page_2-1086x1536.png 1086w, https://www.example.com/wp-content/uploads/2025/12/%E0%B8%9B%E0%B8%A3%E0%B8%B0%E0%B8%81%E0%B8%B2%E0%B8%A8%E0%B8%AA%E0%B8%96%E0%B8%B2%E0%B8%9B%E0%B8%99%E0%B8%B2%E0%B8%AA%E0%B8%A1%E0%B9%80%E0%B8%94%E0%B9%87%E0%B8%88%E0%B8%9E%E0%B8%A3%E0%B8%B0%E0%B9%80%E0%B8%88%E0%B9%89%E0%B8%B2%E0%B8%9A%E0%B8%A3%E0%B8%A1%E0%B9%80%E0%B8%98%E0%B8%AD-%E0%B9%80%E0%B8%88%E0%B9%89%E0%B8%B2%E0%B8%9F%E0%B9%89%E0%B8%B2%E0%B8%81_Page_2-1448x2048.png 1448w"; imagesizes="(width <= 480px) 150px, (600px < width <= 782px) 331px, (782px < width) 542px, (max-width: 1654px) 100vw, 1654px"; media="screen and (782px < width)"
server: nginx
server-timing: wp-before-template;dur=160.05
wpo-cache-message: WordPress login cookies were detected
wpo-cache-status: not cached
x-cache-status: BYPASS

Additional Link: rel=preload headers for other images were present in the same response, further increasing total header size.

Steps to reproduce

  1. Install WordPress on a server using Nginx as a reverse proxy (for example, the default Plesk setup).
  2. Install and activate the Performance Lab plugin.
  3. Enable the Image Prioritizer module.
  4. Create or visit a page containing large images with srcset (default WordPress behavior).
  5. Use image filenames that are long or contain non-ASCII characters.
  6. Log in as an administrator.
  7. Visit the page while logged in.
  8. In some cases, observe a 502 Bad Gateway error and the Nginx log entry: upstream sent too big header.

Screenshots

No screenshots are available because the behavior appears to be intermittent and was no longer reproducible at the time of reporting.

Additional Context

  • PHP Version: 8.1
  • OS: Linux
  • Web Server: Nginx (reverse proxy) + Apache
  • Browser: Chrome
  • Plugin Version: Performance Lab 4.0.0 & Image Prioritizer 1.0.0-beta2
  • Device: Desktop
  • When the issue occurred, response headers contained very large Link preload entries including full srcset and sizes attributes.
  • Increasing Nginx proxy buffer sizes mitigated the issue, indicating that the failure was related to excessive response header size.
  • The behavior appears to be conditional and may depend on viewport size, page content, or prioritization heuristics.
  • Disabling the Image Prioritizer module immediately resolved the issue.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the Image Prioritizer module's generation of Link: rel=preload headers and reproduce the logged-in, uncached-page case with long or non-ASCII image filenames. Check the resulting header size and proxy behavior; done means the module no longer produces headers large enough to trigger Nginx's upstream-too-big-header 502 while preserving image prioritization.

Written by the indexing model from the issue text.

Assessment

Tech stack
nginx, php, wordpress
Domain
backend, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.