Skip to content

Commit 20b446e

Browse files
LeoColombmathiasbynens
authored andcommitted
Add font MIME types per RFC 8081
Closes #114.
1 parent 208946a commit 20b446e

File tree

4 files changed

+19
-18
lines changed

4 files changed

+19
-18
lines changed

src/media_types/media_types.conf

+5-13
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,12 @@
5555

5656
# Web fonts
5757

58-
AddType application/font-woff woff
59-
AddType application/font-woff2 woff2
58+
AddType font/woff woff
59+
AddType font/woff2 woff2
6060
AddType application/vnd.ms-fontobject eot
61-
62-
# Browsers usually ignore the font media types and simply sniff
63-
# the bytes to figure out the font type.
64-
# https://mimesniff.spec.whatwg.org/#matching-a-font-type-pattern
65-
#
66-
# However, Blink and WebKit based browsers will show a warning
67-
# in the console if the following font types are served with any
68-
# other media types.
69-
70-
AddType application/x-font-ttf ttc ttf
71-
AddType font/opentype otf
61+
AddType font/ttf ttf
62+
AddType font/collection ttc
63+
AddType font/otf otf
7264

7365

7466
# Other

src/web_performance/compression.conf

+3
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,11 @@
4141
"application/x-web-app-manifest+json" \
4242
"application/xhtml+xml" \
4343
"application/xml" \
44+
"font/collection" \
4445
"font/eot" \
4546
"font/opentype" \
47+
"font/otf" \
48+
"font/ttf" \
4649
"image/bmp" \
4750
"image/svg+xml" \
4851
"image/vnd.microsoft.icon" \

src/web_performance/expires_headers.conf

+6
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,20 @@
7979

8080
# Web fonts
8181

82+
# Collection
83+
ExpiresByType font/collection "access plus 1 month"
84+
8285
# Embedded OpenType (EOT)
8386
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
8487
ExpiresByType font/eot "access plus 1 month"
8588

8689
# OpenType
8790
ExpiresByType font/opentype "access plus 1 month"
91+
ExpiresByType font/otf "access plus 1 month"
8892

8993
# TrueType
9094
ExpiresByType application/x-font-ttf "access plus 1 month"
95+
ExpiresByType font/ttf "access plus 1 month"
9196

9297
# Web Open Font Format (WOFF) 1.0
9398
ExpiresByType application/font-woff "access plus 1 month"
@@ -96,6 +101,7 @@
96101

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

100106

101107
# Other

test/tests.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ exports = module.exports = {
355355
'test.otf': {
356356
responseHeaders: {
357357
'access-control-allow-origin': '*',
358-
'content-type': 'font/opentype'
358+
'content-type': 'font/otf'
359359
}
360360
},
361361

@@ -436,14 +436,14 @@ exports = module.exports = {
436436
'test.ttc': {
437437
responseHeaders: {
438438
'access-control-allow-origin': '*',
439-
'content-type': 'application/x-font-ttf'
439+
'content-type': 'font/collection'
440440
}
441441
},
442442

443443
'test.ttf': {
444444
responseHeaders: {
445445
'access-control-allow-origin': '*',
446-
'content-type': 'application/x-font-ttf'
446+
'content-type': 'font/ttf'
447447
}
448448
},
449449

@@ -508,15 +508,15 @@ exports = module.exports = {
508508
responseHeaders: {
509509
'access-control-allow-origin': '*',
510510
'content-encoding': null,
511-
'content-type': 'application/font-woff'
511+
'content-type': 'font/woff'
512512
}
513513
},
514514

515515
'test.woff2': {
516516
responseHeaders: {
517517
'access-control-allow-origin': '*',
518518
'content-encoding': null,
519-
'content-type': 'application/font-woff2'
519+
'content-type': 'font/woff2'
520520
}
521521
},
522522

0 commit comments

Comments
 (0)