From 23793d85f3c13a5f239538156021748c98b40183 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C4=83t=C4=83lin=20Mari=C8=99?= Date: Fri, 17 Oct 2014 23:14:50 +0300 Subject: [PATCH] Add configs for `application/x-javascript` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit By default the configurations from this repository ensure that `.js` files are served with the `application/javascript` media type, compressed, and with far future expires headers. However, not all users¹ use all the configurations provided by this project, or in some cases, the headers are overwritten from the level "beneath" Apache (e.g.: from `php`). Looking at the results from the HTTP Archive² from 01.09.2014: +---+--------------------+--------------------------+ | | number of requests | media type | +---+--------------------+--------------------------+ | 1 | 7406888 | image/jpeg | | 2 | 4547461 | image/png | | 3 | 4003685 | image/gif | | 4 | 3087744 | text/html | * | 5 | 2112777 | text/javascript | | 6 | 1798370 | text/css | * | 7 | 1740983 | application/x-javascript | * | 8 | 1394717 | application/javascript | | | ... | ... | +---+--------------------+--------------------------+ it's clear that the `application/javascript` media type is used less often than both `text/javascript` and `application/x-javascript`. Because of the above, the changes from this commit will ensure that Apache will serve anything labeled with the `application/x-javascript`, compressed and with far future expires headers (a previous commit³ did the same for the files labeled as `text/javascript`). - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - ¹ h5bp/server-configs-apache#27 h5bp/server-configs-apache#41 ² https://www.igvita.com/2013/06/20/http-archive-bigquery-web-performance-answers/ Query used: select count(requestid) as number_of_requests, mimetype as media_type from [httparchive:runs.2014_09_01_requests] group by media_type order by number_of_requests desc; ³ https://github.com/h5bp/server-configs-apache/commit/db6932740a90a36cbbf8b38627fc034d595471c0 --- CHANGELOG.md | 1 + dist/.htaccess | 3 +++ src/web_performance/compression.conf | 1 + src/web_performance/expires_headers.conf | 1 + src/web_performance/file_concatenation.conf | 1 + test/fixtures/.htaccess | 3 +++ 6 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index eab24c91..57f1abb5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ### HEAD +* Add configs for files marked as `application/x-javascript`. * Add configs for bitmap image files (`.bmp`) [[77ccf9e](https://github.com/h5bp/server-configs-apache/commit/77ccf9ec101b20c14a05fdfb50c2db47ed490ad4)]. * Compress vCard files (`.vcard`/`.vcf`). diff --git a/dist/.htaccess b/dist/.htaccess index dc7502d4..e1ee92f4 100644 --- a/dist/.htaccess +++ b/dist/.htaccess @@ -714,6 +714,7 @@ AddDefaultCharset utf-8 "application/vnd.geo+json" \ "application/vnd.ms-fontobject" \ "application/x-font-ttf" \ + "application/x-javascript" \ "application/x-web-app-manifest+json" \ "application/xhtml+xml" \ "application/xml" \ @@ -797,6 +798,7 @@ FileETag None # JavaScript ExpiresByType application/javascript "access plus 1 year" + ExpiresByType application/x-javascript "access plus 1 year" ExpiresByType text/javascript "access plus 1 year" # Manifest files @@ -851,6 +853,7 @@ FileETag None # # Options +Includes # AddOutputFilterByType INCLUDES application/javascript \ +# application/x-javascript \ # text/javascript # SetOutputFilter INCLUDES # diff --git a/src/web_performance/compression.conf b/src/web_performance/compression.conf index 2b7b8c4b..5ead4be2 100644 --- a/src/web_performance/compression.conf +++ b/src/web_performance/compression.conf @@ -52,6 +52,7 @@ "application/vnd.geo+json" \ "application/vnd.ms-fontobject" \ "application/x-font-ttf" \ + "application/x-javascript" \ "application/x-web-app-manifest+json" \ "application/xhtml+xml" \ "application/xml" \ diff --git a/src/web_performance/expires_headers.conf b/src/web_performance/expires_headers.conf index 396043fe..a98b4c1a 100644 --- a/src/web_performance/expires_headers.conf +++ b/src/web_performance/expires_headers.conf @@ -35,6 +35,7 @@ # JavaScript ExpiresByType application/javascript "access plus 1 year" + ExpiresByType application/x-javascript "access plus 1 year" ExpiresByType text/javascript "access plus 1 year" # Manifest files diff --git a/src/web_performance/file_concatenation.conf b/src/web_performance/file_concatenation.conf index 8bd4e332..f5d1d9c4 100644 --- a/src/web_performance/file_concatenation.conf +++ b/src/web_performance/file_concatenation.conf @@ -20,6 +20,7 @@ Options +Includes AddOutputFilterByType INCLUDES application/javascript \ + application/x-javascript \ text/javascript SetOutputFilter INCLUDES diff --git a/test/fixtures/.htaccess b/test/fixtures/.htaccess index fdfe6bb2..c3d3e810 100644 --- a/test/fixtures/.htaccess +++ b/test/fixtures/.htaccess @@ -667,6 +667,7 @@ AddDefaultCharset utf-8 "application/vnd.geo+json" \ "application/vnd.ms-fontobject" \ "application/x-font-ttf" \ + "application/x-javascript" \ "application/x-web-app-manifest+json" \ "application/xhtml+xml" \ "application/xml" \ @@ -750,6 +751,7 @@ FileETag None # JavaScript ExpiresByType application/javascript "access plus 1 year" + ExpiresByType application/x-javascript "access plus 1 year" ExpiresByType text/javascript "access plus 1 year" # Manifest files @@ -804,6 +806,7 @@ FileETag None Options +Includes AddOutputFilterByType INCLUDES application/javascript \ + application/x-javascript \ text/javascript SetOutputFilter INCLUDES