IE 11 fails to load resource files - cdn

I have an application employing FontAwesome's glyph fonts for icons, and everything works fine when I host the files from my server. When I enable CDN support on my site, IE 11 behaves rather strangely in regards to the font files. When navigating to a page either via clicking a link or manually entering a URL, the font files load fine ~95% of the time. If I reload a page or use forward/back buttons (or the ~5% of the time a normal page load doesn't work), IE 11 loads the first font file, loses/drops/ignores the contents of the response body somehow, tries to load the second file, loses the contents of the response body, wash-rinse-repeat, and I end up with no font glyphs. All other browsers (including older versions of IE) work fine.
#font-face declaration in CSS:
#font-face {
font-family: 'FontAwesome';
src: url('/common/fonts/fontawesome-webfont.eot');
src: url('/common/fonts/fontawesome-webfont.eot?#iefix') format('embedded-opentype'),
url('/common/fonts/fontawesome-webfont.woff') format('woff'),
url('/common/fonts/fontawesome-webfont.ttf') format('truetype'),
url('/common/fonts/fontawesome-webfont.svg#fontawesomeregular') format('svg');
font-weight: normal;
font-style: normal;
}
Normal page load:
Summary:
URL Protocol Method Result Type Received Taken Initiator Wait Start Request Response‎‎ Cache read‎‎ Gap‎‎
/common/fonts/fontawesome-webfont.eot HTTPS GET 200 application/octet-stream 99.78 KB 109 ms #font-face 2449 0 47 62 0 1420
Response header:
Key Value
Response HTTP/1.1 200 OK
Content-Type application/octet-stream
Last-Modified Mon, 04 Aug 2014 12:49:48 GMT
Accept-Ranges bytes
ETag "07ef492e2afcf1:0"
Server Microsoft-IIS/7.5
P3P CP="NON DSP COR ADM DEV PSA IVA CONi TELi OUR BUS NAV"
Access-Control-Allow-Origin *
Content-Length 101712
Expires Mon, 15 Sep 2014 18:48:40 GMT
Cache-Control max-age=0, no-cache, no-store
Pragma no-cache
Date Mon, 15 Sep 2014 18:48:40 GMT
Connection keep-alive
Response body contains font file.
On page reload:
Summary:
URL Protocol Method Result Type Received Taken Initiator Wait Start Request Response‎‎ Cache read‎‎ Gap‎‎
/common/fonts/fontawesome-webfont.eot HTTPS GET 200 application/octet-stream 462 B 47 ms #font-face 983 0 47 0 0 1248
/common/fonts/fontawesome-webfont.woff HTTPS GET 200 application/x-font-woff 461 B 63 ms #font-face 1092 0 63 0 0 1123
/common/fonts/fontawesome-webfont.ttf HTTPS GET 200 application/octet-stream 462 B 93 ms #font-face 1155 15 78 0 0 1030
Response header (for "fontawesome-webfont.eot", the others look the same, except for differences in content-length, accounting for the differences in file size):
Key Value
Response HTTP/1.1 200 OK
Content-Type application/octet-stream
Last-Modified Mon, 04 Aug 2014 12:49:48 GMT
Accept-Ranges bytes
ETag "07ef492e2afcf1:0"
Server Microsoft-IIS/7.5
P3P CP="NON DSP COR ADM DEV PSA IVA CONi TELi OUR BUS NAV"
Access-Control-Allow-Origin *
Content-Length 101712
Expires Mon, 15 Sep 2014 19:05:13 GMT
Cache-Control max-age=0, no-cache, no-store
Pragma no-cache
Date Mon, 15 Sep 2014 19:05:13 GMT
Connection keep-alive
Response body is empty. Note that content length in the details does not match the "received" value in the summary.
According to CDN logs and tracking traffic locally in Fiddler2, the full font files are being served up by the CDN. As near as I can tell, the response from the CDN is identical to the response from my server.
Enabling caching seems to eliminate the effect (at least, I have not been able to reproduce it with caching enabled), but the Powers That Be are concerned that this will affect other, non-cacheable, assets in the application as more are transitioned over to the CDN, and thus I must find the root cause and fix it rather than slap a band-aid on it.
Why might IE 11 behave as if the responses have empty response bodies? Why might IE 11 treat a response from a CDN differently from a response from the app server, if the files and response headers are the same?

I have been seeing similar issue with the CDN. Am going to update the answer if I find any other solution.
IE has an issue if your font files have no cache set.
I hope this link helps.
On IE CSS font-face works only when navigating through inner links
Update : The issue fixed for me after setting the correct cache control in .htaccess file
I made mine for max-age= 3600 but max-age=0 would work too
<FilesMatch "\.(ttf|otf|eot|woff)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
Header set Cache-Control "max-age=3600"
</IfModule>
</FilesMatch>

MIME types are very important in IE11. You must ensure that the proper MIME types are sent for font files:
application/vnd.ms-fontobject for EOT fonts
application/font-woff for WOFF fonts
What CDN are you using? With the official FontAwesome CDN (http://www.bootstrapcdn.com/#fontawesome_tab), everything should work fine.

For anyone else finding this with the same issue, the following is info, not necessarily a solution.
IE apparently has a bug titled:
#font-face not working with Internet Explorer and HTTP-Header
Pragma=no-cache
They have closed the bug as Won't Fix.
View details here:
http://connect.microsoft.com/IE/feedbackdetail/view/992569/font-face-not-working-with-internet-explorer-and-http-header-pragma-no-cache
I noticed the same issue immediately after adding a few headers to prevent caching, including the pragma header.

So I don't have a good explanantion for why this is failing, but the solution that the one that works, not the one that is ideal. You can burn a good deal of time trying to troubleshoot this and still not get anywhere, there are a ton of variables involved.
Can you set the font fallback to hit your server as opposed to the cdn?
You should be able to specify it in the css that you use one font face, and then another if it fails.
body { font-family:"FontAwesome", "FontAwesomeFallback"; }
Make the FontAwesomeFallback point to your local directory and see if IE11 has the same issue. If it's a CDN issue, hitting your local directories shouldn't be an issue and the font will render properly. If it still fails, it may be an issue with the fontface itself.

Related

Preventing 304 NOT MODIFIED response in Tomcat

If a resource (index.html) is already cached in the client, for example using response header:
"Cache-Control": "max-age=0, must-revalidate, proxy-revalidate"
How can I prevent tomcat to respond with a 304 Not Modifiedin the next request to the server? I would like to force the server to respond with 200 instead of 304 no matter what.
I tried to set
httpResp.setHeader("Cache-Control", "no-cache, no-store, must-revalidate, proxy-revalidate");
httpResp.setHeader("Pragma", "no-cache");
httpResp.setHeader("Expires", "0");
but it only works in the SECOND request. The first request still gets 304.
I tried to override the if-modified-since header using HttpServletRequestWrapper with values in the past such as Mon, 06 Dec 2010 01:34:46 GMT with no luck - client still gets 304 responses although the file was modified in 2015.
Is there any way I can prevent 304 responses? maybe via tomcat configuration?
Not sure if this will help but you could try the following -
Delete the browser cache to start from scratch and test whether this works or not
Adapted from another ServerFault question -
https://serverfault.com/questions/40205/how-do-i-disable-tomcat-caching-im-having-weird-static-file-problems?answertab=votes#tab-top
You might have to delete the application cache folder in /work/Catalina/localhost after changing the cachingAllowed flag.
Configuration can be introduced in server.xml as
<Context className="org.apache.catalina.core.StandardContext"
cachingAllowed="false"
charsetMapperClass="org.apache.catalina.util.CharsetMapper"
cookies="true"
reloadable="false"
wrapperClass="org.apache.catalina.core.StandardWrapper">
</Context>

Browsers don't cache downloaded file when using HTTP Cache-Control header

I have a web application that offers file downloading functionality. I would like to enable browser cache (Cache-Control header) so that subsequent downloads of a file come from the browser cache, instead of generating a new HTTP Request to the server.
HTTP Request:
http://localhost:9080/webapp/action/content/somefile.exe
HTTP Response:
Cache-Control:max-age=600
Content-Disposition:inline;filename="somefile.exe"
Content-Length:20952624
Content-Type:application/x-msdownload
Date:Thu, 22 Oct 2015 10:46:17 GMT
Last-Modified:Thu, 22 Oct 2015 10:44:49 GMT
X-Powered-By:Servlet/3.1
However, despite the Cache-Control header, the browser (latest releases from Firefox & Chrome) always asks the server for the file. Any idea why?

Font Awesome With HTTPS

So I'm experiencing an issue with Font Awesome in IE8 when using HTTPS in my own site and this is even reproducible on Font Awesome's own site. If I go to Font Awesome over HTTPS in IE8 I get boxes for all of the icons however if I go to Font Awesome over HTTP I get the icons rendered correctly.
What is the problem here? I've heard it could be something to do with the relative font paths in Font Awesome over HTTPS but not sure about that.
Here is a screenshot for those who like such things:
Update
So here is the code that references the fonts and loads the CSS. I'm going to use the code from Font Awesome's site since this seems to be an issue with Font Awesome and not
necessarily something with my site:
HTML that references CSS and an icon:
<link rel="stylesheet" href="../assets/css/site.css">
<link rel="stylesheet" href="../assets/css/pygments.css">
<link rel="stylesheet" href="../assets/font-awesome/css/font-awesome.css">
...
<div class="fa-hover col-md-3 col-sm-4">
<i class="fa fa-adjust"></i> fa-adjust
</div>
Within in font-awesome.css:
#font-face {
font-family: 'FontAwesome';
src: url('../fonts/fontawesome-webfont.eot');
src: url('../fonts/fontawesome-webfont.eot?#iefix') format('embedded-opentype'),
url('../fonts/fontawesome-webfont.woff?v=4.0.3') format('woff'),
url('../fonts/fontawesome-webfont.ttf?v=4.0.3') format('truetype'), url('../fonts/fontawesome-webfont.svg?v=4.0.3#fontawesomeregular') format('svg');
font-weight: normal;
font-style: normal;
}
I've determined the issue and will post the answer in case anyone else experiences the same issue. The problem was with the HTTP cache headers we were sending along with the font file. Apparently this causes IE8 over HTTPS to not load the fonts for some reason (if anyone knows the true reason please comment below). The successful headers should look like this:
HTTP/1.1 200 OK
Content-Type: application/vnd.ms-fontobject
Date: Wed, 26 Mar 2014 23:57:04 GMT
ETag: "08b27bc96115c2d24350f0d09e6a9433f"
Last-Modified: Wed, 26 Mar 2014 12:10:02 GMT
Server: Apache-Coyote/1.1
Content-Length: 38205
Connection: keep-alive
but instead were being sent like this:
HTTP/1.1 200 OK
**Cache-Control: max-age=31556926, must-revalidate
Content-Type: application/vnd.ms-fontobject
Date: Wed, 26 Mar 2014 23:58:06 GMT
ETag: "08b27bc96115c2d24350f0d09e6a9433f"
**Expires: Fri, 27 Mar 2015 05:46:52 GMT
Last-Modified: Wed, 26 Mar 2014 12:12:12 GMT
**Pragma: no-cache
Server: Apache-Coyote/1.1
**Set-Cookie: JSESSIONID=844B0798B373A3B8ED54A694C9DFB5C5; Path=/; Secure; HttpOnly
Content-Length: 38205
Connection: keep-alive
This happens in IE only with https.
Remove any HTTP headers from the fontawesome relevant files that prevent caching, e.g.
Expires -1
Pragma: no-cache
After removing the cache control for these files you should see your icons. After reloading your page all the relevant fontawesome files should show HTTP code 304, i.e. the file comes from the browsers cache.
i think the same,
something to do with the relative font paths in Font Awesome over HTTPS
add NoCacheHeaderFilter in web.xml and provide the exclude file paths.
<filter>
<filter-name>NoCacheHeaderFilter</filter-name>
<filter-class>NoCacheHeaderFilter</filter-class>
<init-param>
<param-name>exclude</param-name>
<param-value>^/(image|css|js|fonts|lib|partials)/.*</param-value>
</init-param>
</filter>
add filter like this.
if (null != exclude) {
HttpServletRequest httpRequest = (HttpServletRequest) request;
HttpServletResponse httpResponse = (HttpServletResponse) response;
String context = httpRequest.getContextPath();
String path = httpRequest.getRequestURI().substring(context.length());
if (!exclude.matcher(path).matches()) {
httpResponse.setHeader("Pragma", "no-cache");
httpResponse.setHeader("Cache-Control", "private, max-age=0, no-store, no-cache");
httpResponse.setDateHeader("Expires", System.currentTimeMillis());
}
}
chain.doFilter(request, response);
The practical answer is,using a proxy, to hide to the browser any cache-control and pragma: "no-cache" header returned to the browser.
I used nginx like this, adding the folowing commands the https proxied location:
proxy_hide_header Cache-Control;
proxy_hide_header Pragma;
See here for details.

Download link to RDP file in IE9

I have a website containing a link to an RDP file. When the user clicks the link, the file should be offered as a download. It works with every browser, also in IE9 on localhost. But online, IE9 does not recognize the file type and the file name, and clicking on save causes an error. Did I forget a correct header? Or are there some trusted site settings I have to change since it works on localhost?
I get the following headers when accessing the rdp file:
Date: Mon, 19 Dec 2011 12:58:50 GMT
Content-Disposition: attachment; filename="Demo_WIN.rdp"
Content-Type: application/octet-stream;charset=UTF-8
Content-Length: 72
Keep-Alive: timeout=15, max=46
Connection: Keep-Alive
username:s:Tester431
full address:s:176.1.2.3
domain:s:MYRDP
I think you need to set the content type to "application/rdp". Here are the relevant headers I use, which work on every browser I've tried, including IE9:
Content-Type: application/rdp; charset=utf-8
Content-Disposition: attachment; filename=Application.rdp

Content-Type is correct by still getting "Resource interpreted as Image but transferred with MIME type text/css."?

I'm getting the following warning for a one of css files in my installation:
Resource interpreted as Image but transferred with MIME type text/css.
How to solve this problem?
I'm running apache2 with ruby on rails 2.8.11.
The server is definitely sending the correct content type:
Accept-Ranges:bytes
Connection:Keep-Alive
Content-Encoding:gzip
Content-Length:803
Content-Type:text/css
Date:Wed, 15 Jun 2011 04:20:45 GMT
ETag:"66941-921-49f967c2bd200"
Keep-Alive:timeout=15, max=96
Last-Modified:Tue, 29 Mar 2011 03:16:24 GMT
Server:Apache/2.2.12 (Ubuntu)
Vary:Accept-Encoding
But still, browser is claiming that "resource is interpreted as Image".
I had this same problem and solved it by fixing one of my CSS files.
I changed the code:
body { background:url(''); }
For:
body { background-image:none; }
Explanation:
Since url('') points to itself, and it is a .css file, the browser couldn't find the image it was looking for to fill url.

Resources