Skip to content

Commit

Permalink
Add configs for web application manifest files
Browse files Browse the repository at this point in the history
* Provide examples on how to set the correct MIME type, namely
  `application/manifest+json`.

* Configure Apache to serve these files:

   * compressed
   * with far-future expires headers (as recommended by the
     specification: http://w3c.github.io/manifest/#h_note_7)

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

Specification:

   * http://w3c.github.io/manifest/

Support coming soon to:

   * Chrome: https://code.google.com/p/chromium/issues/detail?id=366145
   * Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=997779

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

Ref: http://w3c.github.io/manifest/
     #29

Close: #29
  • Loading branch information
alrra committed Jun 3, 2014
1 parent 04785b7 commit a7bb757
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 12 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
### HEAD

* Add configs for web application manifest files
[[#29](https://github.com/h5bp/server-configs-apache/issues/29)].
* Don't block access to the content from within the `/.well-known/` directory
[[#31](https://github.com/h5bp/server-configs-apache/issues/31)].
* Forbid access to `.conf` files.
Expand Down
44 changes: 38 additions & 6 deletions src/.htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,38 @@ Options -MultiViews
# http://tools.ietf.org/html/rfc4329#section-7.2
AddType application/javascript js

# Manifest files

# Web application manifest file
# http://w3c.github.io/manifest/

# Because the web application manifest file doesn't have its own unique
# file extension, you can set its MIME type either by matching:

# 1) the exact location of the file (this can be done using a directive
# such as `<Location>`, but it will NOT work in the `.htaccess` file,
# so you will have to do it in the main server configuration file or
# inside of a `<VirtualHost>` container)
#
# e.g.:
#
# <Location "/.well-known/manifest.json">
# AddType application/manifest+json json
# </Location>

# 2) the filename (this can be problematic as you will need to ensure
# that you don't have any other file with the same name as the one
# you gave to your web application manifest file)
#
# e.g.:
#
# <Files "manifest.json">
# AddType application/manifest+json json
# </Files>

AddType application/x-web-app-manifest+json webapp
AddType text/cache-manifest appcache manifest

# Video
AddType video/mp4 f4v f4p m4v mp4
AddType video/ogg ogv
Expand All @@ -140,12 +172,12 @@ Options -MultiViews
AddType application/font-woff woff
AddType application/vnd.ms-fontobject eot

# Browsers usually ignore the font MIME types and simply sniff the bytes
# to figure out the font type.
# Browsers usually ignore the font MIME types and simply sniff the
# bytes to figure out the font type.
# http://mimesniff.spec.whatwg.org/#matching-a-font-type-pattern

# Chrome however, shows a warning if any other MIME types are used for
# the following fonts.
# Chrome however, shows a warning if any other MIME types are used
# for the following fonts.

AddType application/x-font-ttf ttc ttf
AddType font/opentype otf
Expand All @@ -159,12 +191,10 @@ Options -MultiViews
AddType application/octet-stream safariextz
AddType application/x-chrome-extension crx
AddType application/x-opera-extension oex
AddType application/x-web-app-manifest+json webapp
AddType application/x-xpinstall xpi
AddType application/xml atom rdf rss xml
AddType image/webp webp
AddType image/x-icon cur ico
AddType text/cache-manifest appcache manifest
AddType text/vtt vtt
AddType text/x-component htc
AddType text/x-vcard vcf
Expand Down Expand Up @@ -526,6 +556,7 @@ AddDefaultCharset utf-8
application/javascript \
application/json \
application/ld+json \
application/manifest+json \
application/rss+xml \
application/vnd.ms-fontobject \
application/x-font-ttf \
Expand Down Expand Up @@ -606,6 +637,7 @@ FileETag None
ExpiresByType application/javascript "access plus 1 year"

# Manifest files
ExpiresByType application/manifest+json "access plus 1 year"
ExpiresByType application/x-web-app-manifest+json "access plus 0 seconds"
ExpiresByType text/cache-manifest "access plus 0 seconds"

Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/configs/2.2.x.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@
Allow from all
</Directory>

<Location "/.well-known/manifest.json">
AddType application/manifest+json json
</Location>

</VirtualHost>
4 changes: 4 additions & 0 deletions test/fixtures/configs/2.4.x.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@
Require all granted
</Directory>

<Location "/.well-known/manifest.json">
AddType application/manifest+json json
</Location>

</VirtualHost>
45 changes: 39 additions & 6 deletions test/fixtures/content/.htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,38 @@ ErrorDocument 404 /404.html
# http://tools.ietf.org/html/rfc4329#section-7.2
AddType application/javascript js

# Manifest files

# Web application manifest file
# http://w3c.github.io/manifest/

# Because the web application manifest file doesn't have its own unique
# file extension, you can set its MIME type either by matching:

# 1) the exact location of the file (this can be done using a directive
# such as `<Location>`, but it will NOT work in the `.htaccess` file,
# so you will have to do it in the main server configuration file or
# inside of a `<VirtualHost>` container)
#
# e.g.:
#
# <Location "/.well-known/manifest.json">
# AddType application/manifest+json json
# </Location>

# 2) the filename (this can be problematic as you will need to ensure
# that you don't have any other file with the same name as the one
# you gave to your web application manifest file)
#
# e.g.:
#
# <Files "manifest.json">
# AddType application/manifest+json json
# </Files>

AddType application/x-web-app-manifest+json webapp
AddType text/cache-manifest appcache manifest

# Video
AddType video/mp4 f4v f4p m4v mp4
AddType video/ogg ogv
Expand All @@ -140,12 +172,12 @@ ErrorDocument 404 /404.html
AddType application/font-woff woff
AddType application/vnd.ms-fontobject eot

# Browsers usually ignore the font MIME types and simply sniff the bytes
# to figure out the font type.
# Browsers usually ignore the font MIME types and simply sniff the
# bytes to figure out the font type.
# http://mimesniff.spec.whatwg.org/#matching-a-font-type-pattern

# Chrome however, shows a warning if any other MIME types are used for
# the following fonts.
# Chrome however, shows a warning if any other MIME types are used
# for the following fonts.

AddType application/x-font-ttf ttc ttf
AddType font/opentype otf
Expand All @@ -159,12 +191,10 @@ ErrorDocument 404 /404.html
AddType application/octet-stream safariextz
AddType application/x-chrome-extension crx
AddType application/x-opera-extension oex
AddType application/x-web-app-manifest+json webapp
AddType application/x-xpinstall xpi
AddType application/xml atom rdf rss xml
AddType image/webp webp
AddType image/x-icon cur ico
AddType text/cache-manifest appcache manifest
AddType text/vtt vtt
AddType text/x-component htc
AddType text/x-vcard vcf
Expand Down Expand Up @@ -324,6 +354,7 @@ AddDefaultCharset utf-8
# ------------------------------------------------------------------------------

# Block access to directories without a default document.

# You should leave the following uncommented, as you shouldn't allow anyone to
# surf through every directory on your server (which may includes rather private
# places such as the CMS's directories).
Expand Down Expand Up @@ -514,6 +545,7 @@ AddDefaultCharset utf-8
application/javascript \
application/json \
application/ld+json \
application/manifest+json \
application/rss+xml \
application/vnd.ms-fontobject \
application/x-font-ttf \
Expand Down Expand Up @@ -594,6 +626,7 @@ FileETag None
ExpiresByType application/javascript "access plus 1 year"

# Manifest files
ExpiresByType application/manifest+json "access plus 1 year"
ExpiresByType application/x-web-app-manifest+json "access plus 0 seconds"
ExpiresByType text/cache-manifest "access plus 0 seconds"

Expand Down
7 changes: 7 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,13 @@ var tests = [
'content-encoding': undefined,
'content-type': 'application/x-xpinstall'
})
},

'.well-known/manifest.json': {
headers: generateHeaders({
'cache-control': 'max-age=31536000, no-transform',
'content-type': 'application/manifest+json; charset=utf-8'
})
}

}
Expand Down

0 comments on commit a7bb757

Please sign in to comment.