Rounin
Rounin

Reputation: 29511

Is it possible to DEFLATE a .woff2 file in .htaccess in nginx?

I have the following in my global .htaccess file on my nginx server:

# COMPRESS FILES

<IfModule mod_deflate.c>
  
  [...]

  AddOutputFilterByType DEFLATE application/font-woff2
  AddOutputFilterByType DEFLATE font/woff2

  [...]

</IfModule>

I understand there was some controversy a while back over what MIME Type should represent .woff2 files, but I was hoping that one of these lines:

would work.

Apparently, neither does.


Further Info:


Question:

Am I using the wrong MIME Type?

Or is the issue likely to be nginx related?

(Or something else which hasn't crossed my mind yet...) ?

Upvotes: 0

Views: 666

Answers (1)

Irshad
Irshad

Reputation: 67

Most probably you shall modify nginx.conf file to add the required compression.

.htaccess file will not work in NGINX

To have better coverage on compression and performance over NGINX, you may use pagespeed module

https://developers.google.com/speed/pagespeed/module

Example code block for nginx.conf file

gzip on;
gzip_vary on;
zip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_min_length 256;

gzip_types
  font/eot
  font/otf
  font/ttf
  image/svg+xml
  text/css
  text/javascript
  text/plain
  text/xml;

Upvotes: 1

Related Questions