Skip to content

Commit db69327

Browse files
committed
Add configs for files marked as text/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`). For most of these cases we can't do anything about it. Nonetheless, there is one, quite common case (the media type is set to `text/javascript`) where we can help. Since the `text/javascript` media type is used² quite often, this commit makes Apache serve anything labeled with this media type, compressed and with far future expires headers. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ¹ #27 #41 ² Even the Google CND serves `.js` files with the `text/javascript` media type (e.g.: http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js)
1 parent c216a1b commit db69327

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
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 `text/javascript`.
34
* Add configs for JSON Schema files (`.json`)
45
[[#39](https://github.com/h5bp/server-configs-apache/issues/39)].
56

dist/.htaccess

+3-1
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,7 @@ AddDefaultCharset utf-8
632632
"text/cache-manifest" \
633633
"text/css" \
634634
"text/html" \
635+
"text/javascript" \
635636
"text/plain" \
636637
"text/vtt" \
637638
"text/x-component" \
@@ -701,6 +702,7 @@ FileETag None
701702

702703
# JavaScript
703704
ExpiresByType application/javascript "access plus 1 year"
705+
ExpiresByType text/javascript "access plus 1 year"
704706

705707
# Manifest files
706708
ExpiresByType application/manifest+json "access plus 1 year"
@@ -766,7 +768,7 @@ FileETag None
766768
#
767769
# <FilesMatch "\.combined\.js$">
768770
# Options +Includes
769-
# AddOutputFilterByType INCLUDES application/javascript
771+
# AddOutputFilterByType INCLUDES application/javascript text/javascript
770772
# SetOutputFilter INCLUDES
771773
# </FilesMatch>
772774
#

test/fixtures/.htaccess

+3-1
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ AddDefaultCharset utf-8
346346
"text/cache-manifest" \
347347
"text/css" \
348348
"text/html" \
349+
"text/javascript" \
349350
"text/plain" \
350351
"text/vtt" \
351352
"text/x-component" \
@@ -408,6 +409,7 @@ FileETag None
408409

409410
# JavaScript
410411
ExpiresByType application/javascript "access plus 1 year"
412+
ExpiresByType text/javascript "access plus 1 year"
411413

412414
# Manifest files
413415
ExpiresByType application/manifest+json "access plus 1 year"
@@ -458,7 +460,7 @@ FileETag None
458460

459461
<FilesMatch "\.combined\.js$">
460462
Options +Includes
461-
AddOutputFilterByType INCLUDES application/javascript
463+
AddOutputFilterByType INCLUDES application/javascript text/javascript
462464
SetOutputFilter INCLUDES
463465
</FilesMatch>
464466

0 commit comments

Comments
 (0)