'Resource interpreted as Stylesheet but transferred with MIME type text/x-asm

Everything works fine locally but when the stylesheets are uploaded to the server, the styles aren't being applied to the page. Chrome shows this error:

Resource interpreted as Stylesheet but transferred with MIME type text/x-asm

If I open the .css files in Chrome inspector and make any change to them there (including trivial changes such as hitting backspace or enter), then the styles are applied to the page and everything works as it should. But replicating this change in the actual stylesheet and re-uploading to the server does not solve the problem.

I validated the CSS using the W3C CSS Validator in hopes of finding something that would cause a parsing error on the server. All files validate but the problem remains.

Answers to similar questions on Stackoverflow point to server configuration. I'm a front-end developer at a large agency and don't have easy access to server configuration. What's more, stylesheets for other sites being served from that server do not incur that error. And when I link the problematic site to a stylesheet from another site, I get the same error. Which makes me think that the problem isn't server configuration or the stylesheet itself, but something else. I'd post more code but my employer's policy prohibits me from doing so.

Is there anything client side which could be causing this error?



Solution 1:[1]

If your company is using HTTP-Server-Simple-Static for serving CSS file it might be a server bug: https://rt.cpan.org/Public/Bug/Display.html?id=91321 It looks like the used method to autodetect the mime type sometimes get wrong results. Does it help, if you change the first lines of your CSS?

Solution 2:[2]

I had this same problem with Firefox telling me the (static) stylesheet was not loaded because the type of the static CSS file was "text/x-asm" instead of "text/css". Server mime types were all correct. Turned out, the stylesheet had tabs instead of spaces for indentation. I converted the tabs to spaces, and it was served and loaded properly.

Solution 3:[3]

Linux-based Webservers often use a program called file to determine the mimetype of a file to be downloaded.

file appears to have a problem with css if any of your class names start with any of the following:

.asciiz .byte .even .globl .text .file .type

To resolve the problem, rename the offending class.

Reference: https://serverfault.com/questions/597777/how-to-correct-the-mime-type-from-being-recognized-as-text-x-asm-to-text-css

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Stephan Kulla
Solution 2 David Fleming
Solution 3 Phil Y