Compression for form submission/request bodies from the browser



Submitting lots of form data to the server is often slow because most consumer ISPs have very asymmetrical bandwidth, where the download dwarfs the upload.


In robust HTML, this could work as an attribute patterned after <form>’s existing accept-charset attribute.

<form accept-encoding="br gzip deflate" method="post" enctype="multipart/form-data">
  <label>CSV files:
    <input type="file" name="csv-data" accept=".csv" multiple>
Possible issue with attribute name

I seem to recall that hyphenated attribute names have to be special-cased in various parts of the parsing algorithm, so acceptencoding might be more interoperable.

The attribute should contain space-separated compression algorithm tokens — the ones defined for Accept-Encoding and Content-Encoding.

If the server doesn’t accept compressed request bodies, or if doesn’t support the algorithms the browser sends in the Content-Encoding request header, it would return 406 Not Acceptable. The browser then might attempt to send the form data the old-fashioned way.

I’m not sure what the most idiomatic way to do this for fetch would be; adding a Content-Encoding header in the fetch options? Or is that too much magic?


See also: