Skip to content

Commit

Permalink
Add configs for files marked as text/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`).

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)
  • Loading branch information
alrra committed Sep 3, 2014
1 parent c216a1b commit db69327
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -1,5 +1,6 @@
### HEAD

* Add configs for files marked as `text/javascript`.
* Add configs for JSON Schema files (`.json`)
[[#39](https://github.com/h5bp/server-configs-apache/issues/39)].

Expand Down
4 changes: 3 additions & 1 deletion dist/.htaccess
Expand Up @@ -632,6 +632,7 @@ AddDefaultCharset utf-8
"text/cache-manifest" \
"text/css" \
"text/html" \
"text/javascript" \
"text/plain" \
"text/vtt" \
"text/x-component" \
Expand Down Expand Up @@ -701,6 +702,7 @@ FileETag None

# JavaScript
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType text/javascript "access plus 1 year"

# Manifest files
ExpiresByType application/manifest+json "access plus 1 year"
Expand Down Expand Up @@ -766,7 +768,7 @@ FileETag None
#
# <FilesMatch "\.combined\.js$">
# Options +Includes
# AddOutputFilterByType INCLUDES application/javascript
# AddOutputFilterByType INCLUDES application/javascript text/javascript
# SetOutputFilter INCLUDES
# </FilesMatch>
#
Expand Down
4 changes: 3 additions & 1 deletion test/fixtures/.htaccess
Expand Up @@ -346,6 +346,7 @@ AddDefaultCharset utf-8
"text/cache-manifest" \
"text/css" \
"text/html" \
"text/javascript" \
"text/plain" \
"text/vtt" \
"text/x-component" \
Expand Down Expand Up @@ -408,6 +409,7 @@ FileETag None

# JavaScript
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType text/javascript "access plus 1 year"

# Manifest files
ExpiresByType application/manifest+json "access plus 1 year"
Expand Down Expand Up @@ -458,7 +460,7 @@ FileETag None

<FilesMatch "\.combined\.js$">
Options +Includes
AddOutputFilterByType INCLUDES application/javascript
AddOutputFilterByType INCLUDES application/javascript text/javascript
SetOutputFilter INCLUDES
</FilesMatch>

Expand Down

0 comments on commit db69327

Please sign in to comment.