Skip to content

Commit 23793d8

Browse files
committed
Add configs for application/x-javascript
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
1 parent 1a67e57 commit 23793d8

File tree

6 files changed

+10
-0
lines changed

6 files changed

+10
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
### HEAD
22

3+
* Add configs for files marked as `application/x-javascript`.
34
* Add configs for bitmap image files (`.bmp`)
45
[[77ccf9e](https://github.com/h5bp/server-configs-apache/commit/77ccf9ec101b20c14a05fdfb50c2db47ed490ad4)].
56
* Compress vCard files (`.vcard`/`.vcf`).

dist/.htaccess

+3
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,7 @@ AddDefaultCharset utf-8
714714
"application/vnd.geo+json" \
715715
"application/vnd.ms-fontobject" \
716716
"application/x-font-ttf" \
717+
"application/x-javascript" \
717718
"application/x-web-app-manifest+json" \
718719
"application/xhtml+xml" \
719720
"application/xml" \
@@ -797,6 +798,7 @@ FileETag None
797798

798799
# JavaScript
799800
ExpiresByType application/javascript "access plus 1 year"
801+
ExpiresByType application/x-javascript "access plus 1 year"
800802
ExpiresByType text/javascript "access plus 1 year"
801803

802804
# Manifest files
@@ -851,6 +853,7 @@ FileETag None
851853
# <FilesMatch "\.combined\.js$">
852854
# Options +Includes
853855
# AddOutputFilterByType INCLUDES application/javascript \
856+
# application/x-javascript \
854857
# text/javascript
855858
# SetOutputFilter INCLUDES
856859
# </FilesMatch>

src/web_performance/compression.conf

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"application/vnd.geo+json" \
5353
"application/vnd.ms-fontobject" \
5454
"application/x-font-ttf" \
55+
"application/x-javascript" \
5556
"application/x-web-app-manifest+json" \
5657
"application/xhtml+xml" \
5758
"application/xml" \

src/web_performance/expires_headers.conf

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
# JavaScript
3737
ExpiresByType application/javascript "access plus 1 year"
38+
ExpiresByType application/x-javascript "access plus 1 year"
3839
ExpiresByType text/javascript "access plus 1 year"
3940

4041
# Manifest files

src/web_performance/file_concatenation.conf

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<FilesMatch "\.combined\.js$">
2121
Options +Includes
2222
AddOutputFilterByType INCLUDES application/javascript \
23+
application/x-javascript \
2324
text/javascript
2425
SetOutputFilter INCLUDES
2526
</FilesMatch>

test/fixtures/.htaccess

+3
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,7 @@ AddDefaultCharset utf-8
667667
"application/vnd.geo+json" \
668668
"application/vnd.ms-fontobject" \
669669
"application/x-font-ttf" \
670+
"application/x-javascript" \
670671
"application/x-web-app-manifest+json" \
671672
"application/xhtml+xml" \
672673
"application/xml" \
@@ -750,6 +751,7 @@ FileETag None
750751

751752
# JavaScript
752753
ExpiresByType application/javascript "access plus 1 year"
754+
ExpiresByType application/x-javascript "access plus 1 year"
753755
ExpiresByType text/javascript "access plus 1 year"
754756

755757
# Manifest files
@@ -804,6 +806,7 @@ FileETag None
804806
<FilesMatch "\.combined\.js$">
805807
Options +Includes
806808
AddOutputFilterByType INCLUDES application/javascript \
809+
application/x-javascript \
807810
text/javascript
808811
SetOutputFilter INCLUDES
809812
</FilesMatch>

0 commit comments

Comments
 (0)