Skip to content

Commit

Permalink
Add configs for common media types used for .woff
Browse files Browse the repository at this point in the history
By default the configurations from this repository ensure that
`.woff` files are served with the `application/font-woff` media
type 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 15.10.2014:

  +---+--------------------+---------------------------------+
  |   | number of requests |        media type               |
  +---+--------------------+---------------------------------+
  | 1 |              35320 | font/woff                       |
  | 2 |              22128 | application/x-font-woff         |
  | 3 |              19528 | application/octet-stream        |
  | 4 |              17648 | text/plain                      |
  | 5 |               9692 | application/font-woff           |
  |   |                ... |                             ... |
  | 8 |               2496 | font/x-woff                     |
  | 9 |               1804 | application/x-woff              |
  |   |                ... |                             ... |
  +---+--------------------+---------------------------------+

one can see that the `font/woff` and `application/x-font-woff`
media types are used way more often than the IANA registered²
`application/font-woff`.

Other incorrect/unofficial media types are also used, but their
usage is either wrong or low enough to not justify their addition.

Because of the things stated above, the changes from this
commit will ensure that Apache will serve anything labeled with
the `font/woff` or `application/font-woff` media type with far
future expires headers.

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

¹ 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_10_15_requests]
    where (lower(mimetype) contains "woff") or
          (
             regexp_match(lower(url), r'\.woff$') or
             regexp_match(lower(url), r'\.woff\?')
          )
    group by media_type
    order by number_of_requests desc;

² http://www.iana.org/assignments/media-types/application/font-woff
  • Loading branch information
alrra committed Oct 26, 2014
1 parent 7ded752 commit e602ae9
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -1,5 +1,6 @@
### HEAD

* Add configs for common media types used for `.woff` files.
* Add configs for files marked as `text/x-cross-domain-policy`
[[a0c4e17](https://github.com/h5bp/server-configs-apache/commit/a0c4e1719075bf1d97d92a3b0ad225c7bff5dfab)].
* Add configs for files marked as `image/vnd.microsoft.icon`
Expand Down
20 changes: 16 additions & 4 deletions dist/.htaccess
Expand Up @@ -854,18 +854,30 @@ FileETag None
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/svg+xml "access plus 1 month"
ExpiresByType video/mp4 "access plus 1 month"
ExpiresByType video/ogg "access plus 1 month"
ExpiresByType video/webm "access plus 1 month"

# Web fonts
ExpiresByType application/font-woff "access plus 1 month"
ExpiresByType application/font-woff2 "access plus 1 month"

# Embedded OpenType (EOT)
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
ExpiresByType application/x-font-ttf "access plus 1 month"
ExpiresByType font/eot "access plus 1 month"

# OpenType
ExpiresByType font/opentype "access plus 1 month"
ExpiresByType image/svg+xml "access plus 1 month"

# TrueType
ExpiresByType application/x-font-ttf "access plus 1 month"

# Web Open Font Format (WOFF) 1.0
ExpiresByType application/font-woff "access plus 1 month"
ExpiresByType application/x-font-woff "access plus 1 month"
ExpiresByType font/woff "access plus 1 month"

# Web Open Font Format (WOFF) 2.0
ExpiresByType application/font-woff2 "access plus 1 month"

# Other
ExpiresByType text/x-cross-domain-policy "access plus 1 week"
Expand Down
20 changes: 16 additions & 4 deletions src/web_performance/expires_headers.conf
Expand Up @@ -54,18 +54,30 @@
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/svg+xml "access plus 1 month"
ExpiresByType video/mp4 "access plus 1 month"
ExpiresByType video/ogg "access plus 1 month"
ExpiresByType video/webm "access plus 1 month"

# Web fonts
ExpiresByType application/font-woff "access plus 1 month"
ExpiresByType application/font-woff2 "access plus 1 month"

# Embedded OpenType (EOT)
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
ExpiresByType application/x-font-ttf "access plus 1 month"
ExpiresByType font/eot "access plus 1 month"

# OpenType
ExpiresByType font/opentype "access plus 1 month"
ExpiresByType image/svg+xml "access plus 1 month"

# TrueType
ExpiresByType application/x-font-ttf "access plus 1 month"

# Web Open Font Format (WOFF) 1.0
ExpiresByType application/font-woff "access plus 1 month"
ExpiresByType application/x-font-woff "access plus 1 month"
ExpiresByType font/woff "access plus 1 month"

# Web Open Font Format (WOFF) 2.0
ExpiresByType application/font-woff2 "access plus 1 month"

# Other
ExpiresByType text/x-cross-domain-policy "access plus 1 week"
Expand Down
20 changes: 16 additions & 4 deletions test/fixtures/.htaccess
Expand Up @@ -806,18 +806,30 @@ FileETag None
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/svg+xml "access plus 1 month"
ExpiresByType video/mp4 "access plus 1 month"
ExpiresByType video/ogg "access plus 1 month"
ExpiresByType video/webm "access plus 1 month"

# Web fonts
ExpiresByType application/font-woff "access plus 1 month"
ExpiresByType application/font-woff2 "access plus 1 month"

# Embedded OpenType (EOT)
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
ExpiresByType application/x-font-ttf "access plus 1 month"
ExpiresByType font/eot "access plus 1 month"

# OpenType
ExpiresByType font/opentype "access plus 1 month"
ExpiresByType image/svg+xml "access plus 1 month"

# TrueType
ExpiresByType application/x-font-ttf "access plus 1 month"

# Web Open Font Format (WOFF) 1.0
ExpiresByType application/font-woff "access plus 1 month"
ExpiresByType application/x-font-woff "access plus 1 month"
ExpiresByType font/woff "access plus 1 month"

# Web Open Font Format (WOFF) 2.0
ExpiresByType application/font-woff2 "access plus 1 month"

# Other
ExpiresByType text/x-cross-domain-policy "access plus 1 week"
Expand Down

0 comments on commit e602ae9

Please sign in to comment.