From 6ce370780b011cf8e5e5de74c2d9f294d8880768 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C4=83t=C4=83lin=20Mari=C8=99?= Date: Thu, 3 Jul 2014 12:35:06 +0300 Subject: [PATCH] Add configs for WOFF 2.0 font files (`.woff2`) * Serve `.woff2` files with far-future expires headers and with the current specification suggested media type, namely `application/font-woff2` (note: this media type is not yet registered with IANA, however, things aren't likely to change). * Ensure that `.woff2` files aren't served with any of the `HTML` document related headers, and they are accessible even cross-domain. Node: There is no need to compress WOFF 2.0 fonts as they are already compressed! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Huge thanks to Vladimir Levantovsky for all his help! Ref: http://www.w3.org/TR/WOFF2/ h5bp/server-configs-apache#32 Close h5bp/server-configs-apache#32 --- CHANGELOG.md | 2 ++ package.json | 2 +- src/.htaccess | 12 ++++--- test/fixtures/.htaccess | 12 ++++--- test/fixtures/test.woff2 | Bin 0 -> 6168 bytes test/tests.js | 66 +++++++++++++++++++-------------------- 6 files changed, 50 insertions(+), 44 deletions(-) create mode 100644 test/fixtures/test.woff2 diff --git a/CHANGELOG.md b/CHANGELOG.md index ba8587a9..8696c5eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ### HEAD +* Add configs for WOFF 2.0 font files (`.woff2`) + [[#32](https://github.com/h5bp/server-configs-apache/issues/32)]. * Add configs for GeoJSON files (`.geojson`) [[16d3965](https://github.com/h5bp/server-configs-apache/commit/16d39657164a397c8584843296fa04dc297c4b55)]. diff --git a/package.json b/package.json index 62eddb00..ca1b874c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "private": true, "devDependencies": { - "server-configs-test": "https://github.com/h5bp/server-configs-test/tarball/0.1.0" + "server-configs-test": "https://github.com/h5bp/server-configs-test/tarball/0.2.0" }, "scripts": { "test": "server-configs-test" diff --git a/src/.htaccess b/src/.htaccess index 4cc7022e..02e37d50 100644 --- a/src/.htaccess +++ b/src/.htaccess @@ -28,7 +28,7 @@ # By default allow cross-origin access to web fonts. - + Header set Access-Control-Allow-Origin "*" @@ -97,7 +97,7 @@ Options -MultiViews Header set X-UA-Compatible "IE=edge" # `mod_headers` cannot match based on the content-type, however, this header # should be send only for HTML documents and not for the other resources - + Header unset X-UA-Compatible @@ -184,6 +184,7 @@ Options -MultiViews # Web fonts AddType application/font-woff woff + AddType application/font-woff2 woff2 AddType application/vnd.ms-fontobject eot # Browsers usually ignore the font media types and simply sniff @@ -331,7 +332,7 @@ AddDefaultCharset utf-8 # # Header set X-Frame-Options "DENY" -# +# # Header unset X-Frame-Options # # @@ -356,7 +357,7 @@ AddDefaultCharset utf-8 # # Header set Content-Security-Policy "script-src 'self'; object-src 'self'" -# +# # Header unset Content-Security-Policy # # @@ -486,7 +487,7 @@ AddDefaultCharset utf-8 # # # (1) (2) # Header set X-XSS-Protection "1; mode=block" -# +# # Header unset X-XSS-Protection # # @@ -689,6 +690,7 @@ FileETag None # Web fonts ExpiresByType application/font-woff "access plus 1 month" + ExpiresByType application/font-woff2 "access plus 1 month" ExpiresByType application/vnd.ms-fontobject "access plus 1 month" ExpiresByType application/x-font-ttf "access plus 1 month" ExpiresByType font/opentype "access plus 1 month" diff --git a/test/fixtures/.htaccess b/test/fixtures/.htaccess index b0985d30..7907f085 100644 --- a/test/fixtures/.htaccess +++ b/test/fixtures/.htaccess @@ -10,7 +10,7 @@ # ------------------------------------------------------------------------------ - + Header set Access-Control-Allow-Origin "*" @@ -64,7 +64,7 @@ ErrorDocument 404 /404.html Header set X-UA-Compatible "IE=edge" # `mod_headers` cannot match based on the content-type, however, this header # should be send only for HTML documents and not for the other resources - + Header unset X-UA-Compatible @@ -119,6 +119,7 @@ ErrorDocument 404 /404.html # Web fonts AddType application/font-woff woff + AddType application/font-woff2 woff2 AddType application/vnd.ms-fontobject eot AddType application/x-font-ttf ttc ttf @@ -207,7 +208,7 @@ AddDefaultCharset utf-8 Header set X-Frame-Options "DENY" - + Header unset X-Frame-Options @@ -218,7 +219,7 @@ AddDefaultCharset utf-8 Header set Content-Security-Policy "script-src 'self'; object-src 'self'" - + Header unset Content-Security-Policy @@ -279,7 +280,7 @@ AddDefaultCharset utf-8 Header set X-XSS-Protection "1; mode=block" - + Header unset X-XSS-Protection @@ -416,6 +417,7 @@ FileETag None # Web fonts ExpiresByType application/font-woff "access plus 1 month" + ExpiresByType application/font-woff2 "access plus 1 month" ExpiresByType application/vnd.ms-fontobject "access plus 1 month" ExpiresByType application/x-font-ttf "access plus 1 month" ExpiresByType font/opentype "access plus 1 month" diff --git a/test/fixtures/test.woff2 b/test/fixtures/test.woff2 new file mode 100644 index 0000000000000000000000000000000000000000..8ce6cc5e8a3cb251f00b7300f894a1a656d07d12 GIT binary patch literal 6168 zcmV+z80Y7APew8T0RR9102mkm4gdfE04^8+02jaj0UDqH00000000000000000000 z0000RiEtcn24DbG5ey2q6s;2hHUcCAf)o>vLJNTm00bZff_MiY8=5Dx5fyA40EjGi zCyKJfxlu#~Woq_cCfEi{>(O3}i8qH+5k)Mx)?3Be^JW4|Fj$_N9S&l_j4{L*LU=r^ zD*Utm-G?Ma-{E1K{WI#OjfD=C305OwQ6->=Vi1Z!T9}MEqXB0vFqlIZ<($(+>*BkA zF5Pxf{+(CpcX#do>Qdd80(1)4eU=-=2W-oCA=4#3J4951F~eA%`Z`Qq2Eeh)*teI0 zTK=!^ZtuM>Bq5c@$P|SQAv%Od;ZPJpg=j32LKqzO&ya3a0zQM=iL!gITA4$#q5?Y& zv`KY}uelu|Z`x|nd;p{f$q6`}*SSRtpg#X|ulC;}xShE#D?1^p?2LJV!b=KC`IY#U zQ%>>skBTf*CrOP{+A_`%T;(=5ySZt!a}!1q@z2ja%i|{FD`6q@k66Y5#iqeflknR{<4)0NCl7$GKSq+`V2$ax}|;fLcscpmnt(7I=BEZ$1+1|I^WFb9#Or zT!@qMn6!waSzsAB56+W|vlVgaSiT=g1GA%WN~Ku7;+)Ysgp=p9RYVHF2&zRZiGopa z9W*f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$K-o5dT%lk*~>Lz)-+Ai zG)-d*Z_BbQs{;TI2OJIn000000CZih5D)t%2oolR5W=cbN-3q3Qc8K{zQ@z|`FuXeh)E)mNHALiOqG-<(cK2n zO*h?i)B9FEK}CUpfPg@u zkdTm&kkBjiFUhSM2MCZLxDXiHd{Lqw^!V9;xebS3Ep&ZB)FU>w@z0cfkKME2*r_M3Ui6{57v|hc^Nk}@p14f@$V)>fJ9qpb(xyY6*cV2M5!t*; zN$0UwbGG7mut(05-e8@~(_GS{EM_(GA9*|{r074y&pmP$?4JARjp%!x6dyWX5tm?R q9v|-eJjDw=a_FIR_dWKAxtd=w-P_hZRWxhF6zsjbooAi{0001nZ?Y`_ literal 0 HcmV?d00001 diff --git a/test/tests.js b/test/tests.js index d8073acc..3935e2ac 100644 --- a/test/tests.js +++ b/test/tests.js @@ -27,11 +27,11 @@ exports = module.exports = { '\n' + '\n' + '\n' + - ' \n' + - ' 404\n' + + ' \n'+ + ' 404\n' + '\n' + '\n' + - ' 404\n' + + ' 404\n' + '\n' + '\n', responseHeaders: null, @@ -53,11 +53,11 @@ exports = module.exports = { '\n' + '\n' + '\n' + - ' \n' + - ' 404\n' + + ' \n' + + ' 404\n' + '\n' + '\n' + - ' 404\n' + + ' 404\n' + '\n' + '\n', responseHeaders: null, @@ -106,21 +106,21 @@ exports = module.exports = { requestHeaders: null, responseBody: '{\n' + - ' "name": "test",\n' + - ' "icons": [{\n' + - ' "src": "icon/lowres",\n' + - ' "sizes": "64x64",\n' + - ' "type": "image/webp"\n' + - ' }, {\n' + - ' "src": "icon/hd_small",\n' + - ' "sizes": "64x64"\n' + - ' }, {\n' + - ' "src": "icon/hd_hi",\n' + - ' "sizes": "128x128"\n' + - ' }],\n' + - ' "start_url": "/start.html",\n' + - ' "display": "fullscreen",\n' + - ' "orientation": "landscape"\n' + + ' "name": "test",\n' + + ' "icons": [{\n' + + ' "src": "icon/lowres",\n' + + ' "sizes": "64x64",\n' + + ' "type": "image/webp"\n' + + ' }, {\n' + + ' "src": "icon/hd_small",\n' + + ' "sizes": "64x64"\n' + + ' }, {\n' + + ' "src": "icon/hd_hi",\n' + + ' "sizes": "128x128"\n' + + ' }],\n' + + ' "start_url": "/start.html",\n' + + ' "display": "fullscreen",\n' + + ' "orientation": "landscape"\n' + '}\n', responseHeaders: null, }, @@ -146,11 +146,11 @@ exports = module.exports = { '\n' + '\n' + '\n' + - ' \n' + - ' test\n' + + ' \n' + + ' test\n' + '\n' + '\n' + - ' test\n' + + ' test\n' + '\n' + '\n', responseHeaders: null @@ -317,9 +317,9 @@ exports = module.exports = { requestHeaders: null, responseBody: '#test {\n' + - ' background: green;\n' + - ' border: 1px solid green;\n' + - ' color: green;\n' + + ' background: green;\n' + + ' border: 1px solid green;\n' + + ' color: green;\n' + '}\n', responseHeaders: null }, @@ -391,14 +391,14 @@ exports = module.exports = { requestHeaders: null, responseBody: '#test {\n' + - ' background: green;\n' + - ' border: 1px solid green;\n' + - ' color: green;\n' + + ' background: green;\n' + + ' border: 1px solid green;\n' + + ' color: green;\n' + '}\n\n' + '#test {\n' + - ' background: hotpink;\n' + - ' border: 1px solid hotpink;\n' + - ' color: hotpink;\n' + + ' background: hotpink;\n' + + ' border: 1px solid hotpink;\n' + + ' color: hotpink;\n' + '}\n\n', responseHeaders: null },