I have a webpage that is transferring A stylesheet as a text/plain MIME type. what are the possible reasons for this to occur and any tips on how to resolve that problem.
im linking the css like this
<link href="/css/app.css" rel="stylesheet" type='text/css'>
Server misconfiguration. This could depend on an overall configuration error, or on something more limited, like a badly written .htaccess file in the css directory, if the server is running Apache.
Related
I am using Brackets live preview to handle some old website I have. It includes links that use shtml. Note I am not using SNI capabilities on these pages. However, it looks like the content-type sent by the server, is application/shtml, instead of text/html
This forces the file to be downloaded, instead of being displayed. Is there any way to change the content-type for this file? Is there any way to configure it?
Well, I found a solution!
I go into
C:\Program Files (x86)\Brackets\www\extensions\default\StaticServer\node\node_modules\connect\node_modules\send\node_modules\mime\types
I'm editing mime.types
Search for:
text/html html htm
And change it to
text/html html htm shtml
Enjoy!
Occasionally on my websites, I notice an external file won't be loaded. If I rename it and point to the new name it works fine. The old name refuses to work ever again.
Usually this happens with images, but today it happened to a css file. It happens spontaneously and unpredictably. When it happens to images they won't load by themselves in a browser window either. The css will load by itself, but won't be loaded by the page linking to it.
Here are 2 pages which are exactly the same, except they link to 2 differently named css files. The css files are identical, except for their names.
working - http://internetfind.com.au/test2.html
not-working - http://internetfind.com.au/test1.html
The web server is Apache.
Why does this happen and how can I prevent it?
i see on test1 the css file is not loaded as text/css but text/html. I also notice that you are running 2 different domains both running Apache. any chance you have 2 different .htaccess files? I am just speculating here as I dont have all the information but my guess would be the root directory running the test1 domain has a htaccess file where the MIME type are not defined right.
here is a link to a sample .htaccess file that comes with the html5 boilerplate distro. https://github.com/h5bp/html5-boilerplate/blob/master/dist/.htaccess
Another error is that Mordernizr is not defined which probably means that you have not linked the mordernizr library.
My Firefox console reports this:
The stylesheet http://www.agedcarefind.com.au/styles/styles-church.css was not loaded because its MIME type, "text/html", is not "text/css".
This suggests that your server isn't configured correctly and is serving the CSS with the wrong mimetype.
I can confirm the Firefox is requesting the file correctly, and it's being delivered - just not actioned.
test1.html is looking for this CSS
<link href="http://www.agedcarefind.com.au/styles/styles-church.css" type="text/css" rel="stylesheet">
This CSS file is ending with
#prev{position:absolute;z-index:101;height:100%;…
Somwthing is wrong with the file, try to edit it and it should work fine
e.g:
#prev{position:absolute;z-index:101;height:100%;}}
First of all, incorrect content-type for css files Resource interpreted as Stylesheet but transferred with MIME type text/html
Second - Uncaught ReferenceError: Modernizr is not defined
Content-type affects visualization of styles. May be you have some front-end server that changes content-type. Or your files are returned by server-side script - not enough details to answer clearly.
Based on the content of .css files I would say that you have some css compressor (removes white-spaces, new lines, reducing the size of .css file) running on server and may be it affects the content-type header.
Basic Less CSS code works fine when run from local file system:
<link rel="stylesheet/less" href="style.less" type="text/css" />
<script src="less-1.0.21.min.js"></script>
But once I move my code to a HTTP server, Less CSS becomes unable to find the stylesheet file and all the styling gets broken. The server (App Engine) returns *.less as "octetstream" actually. I tried to copy "style.less" to "style.txt" but with no success.
What does Less CSS needs to work on servers?
That depends heavily on your http server. But you can map in most webservers suffixes to mime types per configuration.
In apache something like this could be a solution
AddType text/css .less
See mod_mime
When I change a CSS file and reload the page that includes it, I don't get the changes in my browser.
The only thing that works so far is: rename the css file, rename it back to the original name, reload the web page.
Any ideas what I can do to force apache to give my browser the up-to-date css file?
I have tried:
adding ExpiresByType text/css "access plus 1 second" to my apache VirtualHost configurations
touch mycssfile.css
adding a timestamp as parameter after the name of the css file in the href attribute of the link tag. E.g. href="<link rel="stylesheet" type="text/css" mycssfile.css?{timestamp}" />.
Looks like it's cached by your browser, not Apache itself.
To prevent this you can add something like
ExpiresByType text/css "access minus 1 second"
to your apache config.
In my experience often the caching is done in the browsers.
Try reloading the webpage pressing Ctrl+Shift+R (or Ctrl+F5 on ie).
This should force browsers to ignore files in the cache.
Can someone tell me method to define the MIME-Type of a static XHTML File as text/html …. I don’t want to use php, asp.net…….. javascript would be ok
You shouldn't. Here's why:
Sending XHTML as text/html Considered Harmful (http://hixie.ch/advocacy/xhtml)
If you use XHTML, you should deliver
it with the application/xhtml+xml MIME
type. If you do not do so, you should
use HTML4 instead of XHTML. The
alternative, using XHTML but
delivering it as text/html, causes
numerous problems that are outlined
below.
Use your web server to do it. If you are using apache, create a file called .htaccess in the directory with the file and add this line:
AddType text/html .html