A partial archive of discourse.wicg.io as of Saturday February 24, 2024.

Compression for form submission/request bodies from the browser

Tigt
2018-06-08

Problem

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.

Proposal

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>
  </label>
  <button>Upload</button>
</form>
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?

mnot
2018-06-14

See also: https://httpwg.org/specs/rfc7694.html