Package: apache2
Version: 2.4.25

The default deflate.conf file provided in the Debian package for apache2
instructs the server to consider compressing responses for
application/javascript. [1]

This MIME type is declared as canonical for ".js" by RFC 4329, [2] and is
also associated with ".js" in the default mime.types file. This means for
static JS files served from disk, Apache compresses them out-of-the-box.

However, out in the wild, the text/javascript MIME type is quite common,
if not more common, [3] than application/javascript. As such, when Apache
proxies responses from CGI applications or from other external services,
it often ends up not compressing JavaScript responses.

This is currently known to affect MediaWiki, WordPress, and likely other
popular web applications as well. [4][5] It can be non-trivial for an
upstream like MediaWiki to change this as these MIME types may be deeply
embedded in stable APIs and data structures. For example, it's database
schema and its `ctype` HTTP query parameter both require `text/javascript`.

RFC 4329 defines "equivalent processing requirements for text/javascript,
… and application/javascript". As such, I think Apache2 should consider
both of these for compression by default.

This has the potential to have a big impact on the web. As an example, there
seem to be lots of public MediaWiki sites out there who use Debian Linux (or
downstreams like Ubuntu), and have mod_deflate enabled with the default
compression for text/html and text/css, but have apparently not realised the
lack of JS compression and/or were unable to configure it. [6]

I am new to Debian and its bug tracker and would be interested in submitting
a patch for this if the request is accepted.

-- Timo Tijhof

Principal Engineer,
Performance Team,
Wikimedia Foundation.

[1] Original patch:
https://salsa.debian.org/apache-team/apache2/-/commit/4d93abc8899873ff27080f9261093a02e47320e4

[2] RFC 4329: https://tools.ietf.org/html/rfc4329

[3] text/javascript might become the canonical instead:
https://datatracker.ietf.org/doc/draft-ietf-dispatch-javascript-mjs/

[4] WordPress:
https://github.com/WordPress/WordPress/blob/5.4.1/wp-includes/SimplePie/Misc.php#L2130

[5] MediaWiki:
https://gerrit.wikimedia.org/g/mediawiki/core/+/1.34.1/includes/resourceloader/ResourceLoader.php#892

[6] StackOverflow: https://duckduckgo.com/?q=stackoverflow+
"text%2Fjavascript"+"apache"+"deflate"

Reply via email to