Skip to content

Commit

Permalink
Add configs for application/x-javascript
Browse files Browse the repository at this point in the history
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`).

- - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - -

¹ #27
  #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;

³ db69327
  • Loading branch information
alrra committed Oct 17, 2014
1 parent 1a67e57 commit 23793d8
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`).
Expand Down
3 changes: 3 additions & 0 deletions dist/.htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -851,6 +853,7 @@ FileETag None
# <FilesMatch "\.combined\.js$">
# Options +Includes
# AddOutputFilterByType INCLUDES application/javascript \
# application/x-javascript \
# text/javascript
# SetOutputFilter INCLUDES
# </FilesMatch>
Expand Down
1 change: 1 addition & 0 deletions src/web_performance/compression.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down
1 change: 1 addition & 0 deletions src/web_performance/expires_headers.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/web_performance/file_concatenation.conf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<FilesMatch "\.combined\.js$">
Options +Includes
AddOutputFilterByType INCLUDES application/javascript \
application/x-javascript \
text/javascript
SetOutputFilter INCLUDES
</FilesMatch>
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/.htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -804,6 +806,7 @@ FileETag None
<FilesMatch "\.combined\.js$">
Options +Includes
AddOutputFilterByType INCLUDES application/javascript \
application/x-javascript \
text/javascript
SetOutputFilter INCLUDES
</FilesMatch>
Expand Down

0 comments on commit 23793d8

Please sign in to comment.