Skip to content

[Feature Request] Option to compress payload in a callback #3924

Description

@datenzauberai

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 = 500_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 500,000 bytes (500 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.

If this is of interest I would be happy to submit a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions