Skip to content

Commit

Permalink
[apache] Add Open Web App Manifest configs
Browse files Browse the repository at this point in the history
An Open Web App manifest file (having the extension `.webapp`):

* must be served with a `Content-Type` header of
  `application/x-web-app-manifest+json` (this is currently not enforced
  by Firefox but is enforced by the Firefox Marketplace while, Firefox
  OS only checks this if the origin of the page where the user triggers
  the install is different from the origin of the app itself)

* must be UTF-8 encoded in order to be submitted to the Firefox
  Marketplace

* should not be cached (the expires headers for the manifest are usually
  ignored by Firefox but, just to be sure):

  "Webapps.jsm <http://mxr.mozilla.org/mozilla-central/source/dom/apps/src/Webapps.jsm>
  sets INHIBIT_CACHING <http://mxr.mozilla.org/mozilla-central/source/netwerk/base/public/nsIRequest.idl#141>
  when it downloads the manifest, which prevents Firefox from caching it
  so, in theory the Firefox app runtime won't take expires headers into
  consideration. However, INHIBIT_CACHING doesn't prevent the runtime
  from using an entry in the cache if it exists so, if you load the
  manifest yourself, f.e. to see what it looks like, while developing
  your app, Firefox might cache it, and Webapps.jsm might then get the
  cached version.
  ...
  Webapps.jsm is the implementation of the DOMApplicationRegistry that
  is responsible for managing app records, including their manifests"

                            ~ thanks to @mykmelez for the explanation ~

* is a JSON file so, it can be compressed (the manifest validator
  <https://marketplace.firefox.com/developers/validator>, doesn't seem
  to mind)

* doesn't need any of the extra headers (e.g.:`Content-Security-Policy`,
  `X-UA-Compatible`, etc.)

Reference: https://developer.mozilla.org/en-US/docs/Apps/Manifest
  • Loading branch information
alrra committed Mar 28, 2013
1 parent c68da94 commit 5652ebd
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions apache/.htaccess
Expand Up @@ -92,7 +92,7 @@ Options -MultiViews
Header set X-UA-Compatible "IE=edge,chrome=1"
# `mod_headers` can't match based on the content-type, however, we only
# want to send this header for HTML pages and not for the other resources
<FilesMatch "\.(appcache|crx|css|eot|gif|htc|ico|jpe?g|js|m4a|m4v|manifest|mp4|oex|oga|ogg|ogv|otf|pdf|png|safariextz|svg|svgz|ttf|vcf|webm|webp|woff|xml|xpi)$">
<FilesMatch "\.(appcache|crx|css|eot|gif|htc|ico|jpe?g|js|m4a|m4v|manifest|mp4|oex|oga|ogg|ogv|otf|pdf|png|safariextz|svg|svgz|ttf|vcf|webapp|webm|webp|woff|xml|xpi)$">
Header unset X-UA-Compatible
</FilesMatch>
</IfModule>
Expand Down Expand Up @@ -187,7 +187,7 @@ AddDefaultCharset utf-8

# Force UTF-8 for certain file formats.
<IfModule mod_mime.c>
AddCharset utf-8 .atom .css .js .json .rss .vtt .xml
AddCharset utf-8 .atom .css .js .json .rss .vtt .webapp .xml
</IfModule>


Expand Down Expand Up @@ -279,7 +279,7 @@ AddDefaultCharset utf-8

# <IfModule mod_headers.c>
# Header set Content-Security-Policy "script-src 'self'; object-src 'self'"
# <FilesMatch "\.(appcache|crx|css|eot|gif|htc|ico|jpe?g|js|m4a|m4v|manifest|mp4|oex|oga|ogg|ogv|otf|pdf|png|safariextz|svg|svgz|ttf|vcf|webm|webp|woff|xml|xpi)$">
# <FilesMatch "\.(appcache|crx|css|eot|gif|htc|ico|jpe?g|js|m4a|m4v|manifest|mp4|oex|oga|ogg|ogv|otf|pdf|png|safariextz|svg|svgz|ttf|vcf|webapp|webm|webp|woff|xml|xpi)$">
# Header unset Content-Security-Policy
# </FilesMatch>
# </IfModule>
Expand Down Expand Up @@ -389,6 +389,7 @@ AddDefaultCharset utf-8
application/rss+xml \
application/vnd.ms-fontobject \
application/x-font-ttf \
application/x-web-app-manifest+json \
application/xhtml+xml \
application/xml \
font/opentype \
Expand Down Expand Up @@ -442,9 +443,6 @@ FileETag None

ExpiresDefault "access plus 1 month"

# Appcache manifest
ExpiresByType text/cache-manifest "access plus 0 seconds"

# CSS
ExpiresByType text/css "access plus 1 year"

Expand All @@ -465,6 +463,10 @@ FileETag None
# JavaScript
ExpiresByType application/javascript "access plus 1 year"

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

# Media (audio, image & video formats)
ExpiresByType audio/ogg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
Expand Down

0 comments on commit 5652ebd

Please sign in to comment.