This site uses cookies. Continue to use the site as normal if you are happy with this, or read more about cookies and how to manage them.

×

This site uses cookies. Continue to use the site as normal if you are happy with this, or read more about cookies and how to manage them.

×

Internet Explorer ignores fonts over SSL

Fonts

So we hit an interesting issue today - Internet Explorer 11 wouldn't load fonts via a Spring Boot application, but only when Nginx was being used as a proxy. IE would request the font file e.g. a WOFF file, then seem to ignore it and try another e.g. a TTF and EOT, and finally give up, meaning our Bootstrap icons weren't being displayed. After a lot of head scratching and comparing headers between Spring and Nginx, we found that what made the difference was whether SSL was used or not. Fetching fonts from Nginx without SSL worked fine.

A quick google turned up a relevant Stackoverflow answer. It turns out when IE fetches a font over SSL, if the cache headers state that the font should not be cached, then IE will simply ignore the font . The component responsible for adding the cache headers is Spring Security - you can tell Spring Security to avoid handling matching resource requests at all (and therefore avoid adding caching headers) with:

@Configuration
@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER)
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {

    @Override
    public void configure(WebSecurity web) throws Exception {
        web.ignoring().antMatchers("/fonts/*");
    }
    // rest of config...
}

If you then want to then allow resources to be cached, you could use a WebMvcConfigurerAdapter, e.g.:

@Configuration
public class WebMvcConfig extends WebMvcConfigurerAdapter {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/fonts/**").setCachePeriod(3600);
    }
}

While we can hope that Microsoft's Edge browser will eventually bring resolve these kinds of issues, for anyone supporting older versions of IE (and that's pretty much everyone) it's important to be aware of these kinds of issues, and even more important, to test your code!