15

I am interested in serving gzipped html/css/js files using Firebase Hosting. I tried setting the Content-Encoding header in firebase.json, but it errors on deploy.

purportedly, the only headers you can set include: Cache-Control,Access-Control-Allow-Origin,X-UA-Compatible,X-Content-Type-Options,X-Frame-Options,X-XSS-Protection

any ideas out there?

klq
  • 151
  • 1
  • 1
  • 5

1 Answers1

38

By default, Firebase Hosting already gzips all of your files. Here, for example, are the response headers for a css file I have hosted on firebase. Note the Content-Encoding header:

Accept-Ranges:bytes
Cache-Control:max-age=7178000
Connection:keep-alive
Content-Encoding:gzip
Content-Length:3483
Content-Type:text/css; charset=utf-8
Date:Sun, 10 Jan 2016 02:09:57 GMT
ETag:"4c94283e07340e9cc0237fc2a349c94d"
Last-Modified:Sun, 10 Jan 2016 00:10:31 GMT
Server:nginx
Strict-Transport-Security:max-age=31556926; includeSubDomains; preload
Vary:Accept-Encoding
Via:1.1 varnish
X-Cache:HIT
X-Cache-Hits:1
X-Powered-By:Express
X-Served-By:cache-lax1432-LAX
Sebastian Sandqvist
  • 1,829
  • 2
  • 16
  • 19
  • well yep, it looks like it does. now I need to figure out why my request is not giving the Accepts-Encoding header. thanks Sebasstian! – klq Jan 11 '16 at 14:16
  • 3
    i dont know if something changed but my css file is returned with the following, there is NO Content Encoding: ```Accept-Ranges:bytes Cache-Control:max-age=31536000 Connection:keep-alive Content-Length:3360 Content-Type:text/css; charset=utf-8 Date:Thu, 15 Sep 2016 00:56:13 GMT ETag:"83bab03bd7b4d7f01f03858b2c1e58a2" Last-Modified:Wed, 14 Sep 2016 07:08:13 GMT Server:nginx Strict-Transport-Security:max-age=31556926; includeSubDomains; preload Vary:Accept-Encoding Via:1.1 varnish X-Cache:HIT X-Cache-Hits:1 X-Powered-By:Express X-Served-By:cache-sjc3135-SJC``` – jasan Sep 15 '16 at 00:56
  • even though my Request Header includes ```Accept:text/css,*/*;q=0.1 Accept-Encoding:gzip, deflate, sdch, br``` – jasan Sep 15 '16 at 00:58