Skip to content

Commit e602ae9

Browse files
committed
Add configs for common media types used for .woff
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
1 parent 7ded752 commit e602ae9

File tree

4 files changed

+49
-12
lines changed

4 files changed

+49
-12
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
### HEAD
22

3+
* Add configs for common media types used for `.woff` files.
34
* Add configs for files marked as `text/x-cross-domain-policy`
45
[[a0c4e17](https://github.com/h5bp/server-configs-apache/commit/a0c4e1719075bf1d97d92a3b0ad225c7bff5dfab)].
56
* Add configs for files marked as `image/vnd.microsoft.icon`

dist/.htaccess

+16-4
Original file line numberDiff line numberDiff line change
@@ -854,18 +854,30 @@ FileETag None
854854
ExpiresByType image/gif "access plus 1 month"
855855
ExpiresByType image/jpeg "access plus 1 month"
856856
ExpiresByType image/png "access plus 1 month"
857+
ExpiresByType image/svg+xml "access plus 1 month"
857858
ExpiresByType video/mp4 "access plus 1 month"
858859
ExpiresByType video/ogg "access plus 1 month"
859860
ExpiresByType video/webm "access plus 1 month"
860861

861862
# Web fonts
862-
ExpiresByType application/font-woff "access plus 1 month"
863-
ExpiresByType application/font-woff2 "access plus 1 month"
863+
864+
# Embedded OpenType (EOT)
864865
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
865-
ExpiresByType application/x-font-ttf "access plus 1 month"
866866
ExpiresByType font/eot "access plus 1 month"
867+
868+
# OpenType
867869
ExpiresByType font/opentype "access plus 1 month"
868-
ExpiresByType image/svg+xml "access plus 1 month"
870+
871+
# TrueType
872+
ExpiresByType application/x-font-ttf "access plus 1 month"
873+
874+
# Web Open Font Format (WOFF) 1.0
875+
ExpiresByType application/font-woff "access plus 1 month"
876+
ExpiresByType application/x-font-woff "access plus 1 month"
877+
ExpiresByType font/woff "access plus 1 month"
878+
879+
# Web Open Font Format (WOFF) 2.0
880+
ExpiresByType application/font-woff2 "access plus 1 month"
869881

870882
# Other
871883
ExpiresByType text/x-cross-domain-policy "access plus 1 week"

src/web_performance/expires_headers.conf

+16-4
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,30 @@
5454
ExpiresByType image/gif "access plus 1 month"
5555
ExpiresByType image/jpeg "access plus 1 month"
5656
ExpiresByType image/png "access plus 1 month"
57+
ExpiresByType image/svg+xml "access plus 1 month"
5758
ExpiresByType video/mp4 "access plus 1 month"
5859
ExpiresByType video/ogg "access plus 1 month"
5960
ExpiresByType video/webm "access plus 1 month"
6061

6162
# Web fonts
62-
ExpiresByType application/font-woff "access plus 1 month"
63-
ExpiresByType application/font-woff2 "access plus 1 month"
63+
64+
# Embedded OpenType (EOT)
6465
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
65-
ExpiresByType application/x-font-ttf "access plus 1 month"
6666
ExpiresByType font/eot "access plus 1 month"
67+
68+
# OpenType
6769
ExpiresByType font/opentype "access plus 1 month"
68-
ExpiresByType image/svg+xml "access plus 1 month"
70+
71+
# TrueType
72+
ExpiresByType application/x-font-ttf "access plus 1 month"
73+
74+
# Web Open Font Format (WOFF) 1.0
75+
ExpiresByType application/font-woff "access plus 1 month"
76+
ExpiresByType application/x-font-woff "access plus 1 month"
77+
ExpiresByType font/woff "access plus 1 month"
78+
79+
# Web Open Font Format (WOFF) 2.0
80+
ExpiresByType application/font-woff2 "access plus 1 month"
6981

7082
# Other
7183
ExpiresByType text/x-cross-domain-policy "access plus 1 week"

test/fixtures/.htaccess

+16-4
Original file line numberDiff line numberDiff line change
@@ -806,18 +806,30 @@ FileETag None
806806
ExpiresByType image/gif "access plus 1 month"
807807
ExpiresByType image/jpeg "access plus 1 month"
808808
ExpiresByType image/png "access plus 1 month"
809+
ExpiresByType image/svg+xml "access plus 1 month"
809810
ExpiresByType video/mp4 "access plus 1 month"
810811
ExpiresByType video/ogg "access plus 1 month"
811812
ExpiresByType video/webm "access plus 1 month"
812813

813814
# Web fonts
814-
ExpiresByType application/font-woff "access plus 1 month"
815-
ExpiresByType application/font-woff2 "access plus 1 month"
815+
816+
# Embedded OpenType (EOT)
816817
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
817-
ExpiresByType application/x-font-ttf "access plus 1 month"
818818
ExpiresByType font/eot "access plus 1 month"
819+
820+
# OpenType
819821
ExpiresByType font/opentype "access plus 1 month"
820-
ExpiresByType image/svg+xml "access plus 1 month"
822+
823+
# TrueType
824+
ExpiresByType application/x-font-ttf "access plus 1 month"
825+
826+
# Web Open Font Format (WOFF) 1.0
827+
ExpiresByType application/font-woff "access plus 1 month"
828+
ExpiresByType application/x-font-woff "access plus 1 month"
829+
ExpiresByType font/woff "access plus 1 month"
830+
831+
# Web Open Font Format (WOFF) 2.0
832+
ExpiresByType application/font-woff2 "access plus 1 month"
821833

822834
# Other
823835
ExpiresByType text/x-cross-domain-policy "access plus 1 week"

0 commit comments

Comments
 (0)