Skip to content

Proposal: Enable Gzip Compression for Bid Requests in Prebid.js #12973

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
pm-harshad-mane opened this issue Apr 7, 2025 · 3 comments · May be fixed by #13033
Open

Proposal: Enable Gzip Compression for Bid Requests in Prebid.js #12973

pm-harshad-mane opened this issue Apr 7, 2025 · 3 comments · May be fixed by #13033

Comments

@pm-harshad-mane
Copy link
Contributor

pm-harshad-mane commented Apr 7, 2025

Proposal: Enable Gzip Compression for Bid Requests in Prebid.js

Summary

Over time, the size of OpenRTB (ORTB) bid request payloads in Prebid.js has grown significantly due to the inclusion of consent strings, multiple user IDs, and other metadata. Currently, most bid requests sent by Prebid.js are in plain-text format without any form of compression, even though many bidder servers compress their responses.

Modern browsers support Gzip compression via JavaScript APIs. If Prebid.js utilizes Gzip to compress the request payload (based on bidder configuration), it could reduce the payload size by approximately 45% to 55%. This not only reduces the number of HTTP packets needed but also improves transmission efficiency and performance.

Proposal

  1. Introduce Gzip Support in Prebid.js

    • Core logic will validate the browser support for GZip Compression
    • Use Gzip compression on bid requests where enabled via bidder-level configuration.
    • Ensure compression is handled using browser-native compression APIs.
  2. Bidder-Level Configuration

    • A config flag on the ajax call at the bidder level (e.g., enableGzip: true) should determine whether Gzip is applied to that bidder’s requests.
    • Bidder servers must be capable of decompressing Gzipped payloads.
  3. Prebid Server Changes

    • Prebid Server must be updated to support Gzip-compressed POST request bodies.
    • After this support is in place, we can update Prebid.js to enable Gzip for Prebid Server as a bidder.

Avoiding Preflight Requests

Prebid.js avoids adding custom headers like Content-Encoding to prevent CORS preflight (OPTIONS) requests. To support Gzip compression without triggering preflight:

  • Instead of adding the Content-Encoding header, append a query parameter to the request URL (e.g., ?gzip=1) when the payload is compressed.
  • This informs bidder servers that they should decompress the incoming request body without requiring additional headers that would otherwise trigger a preflight request.

How about using Protobuf?

  • Protobuf ties payload structure to a schema definition, requiring additional maintenance and tooling.
  • It adds a significant library footprint to the Prebid.js bundle.
  • Gzip implementation is lightweight and schema-agnostic.
  • While Protobuf + Gzip could yield even better compression, the overhead of introducing Protobuf makes it a less favorable short-term solution.
@dgirardi
Copy link
Collaborator

dgirardi commented Apr 8, 2025

Related: #9774

@patmmccann patmmccann moved this from Triage to Needs Req in Prebid.js Tactical Issues table Apr 8, 2025
@patmmccann
Copy link
Collaborator

also related is #12889

@patmmccann patmmccann marked this as a duplicate of #9774 Apr 9, 2025
@patmmccann patmmccann moved this from Needs Req to Ready for Dev in Prebid.js Tactical Issues table Apr 9, 2025
@jlquaccia jlquaccia linked a pull request Apr 25, 2025 that will close this issue
1 task
@pm-harshad-mane
Copy link
Contributor Author

We have raised a PR to support GZip Requests feature
#13033

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: PR submitted
Development

Successfully merging a pull request may close this issue.

3 participants