plotly / plotly/dash

[Feature Request] Option to compress request payload in a callback

Open
#3,924 1 comment 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement P3 size: 3
Dominant language
Python
Stars
24.4k
Forks
2.3k
Avg merge
2d 7h
Merged PRs (30d)
13

Description

Problem
While the payload of the HTTP response bodies can be compressed in case of transmitting large amounts of data from the server side to the client, this is not possible for the actual HTTP request body of a callback that sends this data to the server side.

Grids are notoriously using huge JSON structures of several megabytes. Transmitting this data via the network can make the application feel sluggish.

Solution
We could have an option to compress the body of a server side callback on the client side. We could introduce two new parameters for the callback:

compress_payload: bool = False: If True, the callback request payload will be compressed using gzip compression before being sent to the server. Defaults to False.
compress_threshold: int = 5_000: The size threshold in bytes above which the payload will be compressed when compress_payload is True. Set to 0 to always compress regardless of size. Defaults to 5,000 bytes (5 kB).

Alternatives
This can partially be simulated by using client-side callbacks that compress and copy the data to a compressed dcc.Store and then rewire the callbacks to use that store and decompress on the server side. However, this bloats the code and application state.

See referenced PR for more details: https://github.com/plotly/dash/pull/3925

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 reading the callback request handling and the referenced PR #3925 for the proposed approach. Done means callbacks can opt into gzip compression, apply the stated payload-size threshold, and preserve the default uncompressed behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend-api-design
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.