debite
debite

Reputation: 444

Chromium @font-face caching behavior (FOIT)

I noticed a flash of invisible text (FOIT) in Chromium based browsers (Google Chrome and Opera) on some websites, even when the web font file is already cached (browsing on the same site beyond the first load).

A more in-depth look reveals that this has something to do with the caching behavior. A FOIT only happens when the file is loaded from disk cache. Everything looks pretty steady, when the file is served from memory cache (following the built-in web inspector tool).

How can we influence in which cache the web fonts are placed?

Upvotes: 4

Views: 1197

Answers (1)

debite
debite

Reputation: 444

Chromium based browsers seem to load gzipped content to disk cache. At least that’s the reason why the used .woff2 files weren’t loaded to memory cache.

As long as woff/woff2 files are already compressed, further gzipping is not necessary (http://www.phpied.com/font-face-gzipping-take-ii/). The bespoken FOIT was gone when I disabled compression for these files (some web servers enable compression for all files by default).

When using Apache as web server this can be archived with the following line of code:

SetEnvIfNoCase Request_URI \.(?:woff|woff2)$ no-gzip

Upvotes: 2

Related Questions