SOLUTION: It turns out it is not my config / NGINX faults - my DNS provider, cloudflare, is preventing the fonts from being GZipped for some reason

I'm using NGINX with GZIP_Static module installed.

I'm trying to get my .SVG/.TTF @FONT-FACE font files to be served via GZip, as there will be a reduction in about 50% file size. I've added the following mimetypes to the mime.types file:

image/svg+xml                         svg;
application/x-font-ttf                ttf;
font/opentype                         otf;
application/vnd.ms-fontobject         eot;
font/x-woff                           woff;

The fonts are all placed in a single folder, so I first tried setting up folder-specific gzip settings as follows:

location /sites/default/files/fontyourface/local_fonts/ {
      gzip_types image/svg+xml application/x-font-ttf font/opentype ; 

That didn't work, so I tried just adding the Mime types to the "universal" gzip_types definition in nginx.conf - that didn't work either.

I've gone in and manually gzipped the font files so GZIP_Static can be used. That didn't work either.

Any ideas as to what I am doing wrong / how I can set NGINX up to return the GZIP'd versions of only .SVG and .TTF files?

  • 2
    Font files never change; why not preprocess them? – Ignacio Vazquez-Abrams Oct 15 '11 at 4:39
  • They are pre-compressed; the problem here was the headers were not stating the contents as GZipped – Professor Frink Oct 15 '11 at 13:53
  • 1
    What does your DNS provider have to do with your web server (other than telling others how to get to it of course)? – Ignacio Vazquez-Abrams Oct 15 '11 at 19:20

CloudFlare will only gzip TTFs if they are transferred with one of these mime types:

  • font/ttf
  • application/ttf
  • application/x-ttf

Source: https://support.cloudflare.com/hc/en-us/articles/200168396-What-will-CloudFlare-gzip-

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.