Basically I have:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="main.css"/>
by doing this I get a console error saying: main.css was not loaded because its MIME type, “text/html”, is not “text/css”.
through sniffing my browser network tab, It appears that the request is made as text/css but the response comes as text/html.
Request Headers (0.361 KB):
User-Agent: "Mozilla/5.0 (X11; linux x86_64; rv:52.0) gecko/20100101"
Accept: "text/css,*/*;q=0.1"
Accept-language: "en-US, e;q=0.5"
Accept-Encoding: "gzip, deflate"
Response Header (0.123 KB):
Content-Type: "text/html;charset=ISO-8859-1"
Date:"FRI 20 Oct 2017 ..."
Transfer-Encoding: "chunked"
FYI: This stylesheet is request in mutiple pages, at the other pages it works but not here.
Much regards
Related
I have a slideshow that I preview (custom html/js) and to make sure that I get the most recent version from the DB every time I start the slideshow preview, I have these cache statements in my html file
<!DOCTYPE html>
<!-- preview:[true]-->
<HEAD>
<title>screen</title>
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
However sometimes I still need to empty out the browser cache in order to get the most recent updates.
Is there anything else I can put in the head of my html file to prevent browsers from caching this for me? Chrome is what I mainly use, and where I have sometimes experienced this effect, but I would like a generic answer for all browsers.
---------------- UPDATE -------------------
So I included some cache control headers (thanks arkascha) but am still a bit suspicious =)
Here is what I added to my response (php/sym2)
$response->expire();
$now = new \DateTime("now");
$response->setCache(array(
'last_modified' => $now,
'max_age' => 0,
's_maxage' => 0,
'private' => true,
));
And that gives me the following Response headers
Cache-Control:max-age=0, private, s-maxage=0
Connection:Keep-Alive
Content-Type:text/html; charset=UTF-8
Date:Wed, 31 May 2017 08:41:19 GMT
Keep-Alive:timeout=5, max=100
Last-Modified:Wed, 31 May 2017 08:41:20 GMT
Server:Apache/2.2.25 (Unix) mod_ssl/2.2.25 OpenSSL/0.9.8zh DAV/2 PHP/5.5.3
Transfer-Encoding:chunked
X-Powered-By:PHP/5.5.3
... and Request Headers displays as:
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate, sdch, br
Accept-Language:sv-SE,sv;q=0.8,en-US;q=0.6,en;q=0.4
Cache-Control:max-age=0
Connection:keep-alive
Cookie:main=1111111; PHPSESSID=70c2e1a6f81a9d3dad59ed908f25b585
Host:localhost
If-Modified-Since:Wed, 31 May 2017 08:40:18 GMT
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36
But on my network tab (chrome) I still see a lot of "from memory cache" and "from disk cache" in the "size" column for different resources (what is the difference between those two by the way?).
Does the http header only affect the current page and not the associated resources such as .json files?
I dynamically generate an html page in an .aspx file like this:
Response.Clear()
Response.ClearContent()
Response.ClearHeaders()
Response.Buffer = True
Response.ContentType = "text/HTML"
Response.AddHeader("Content-Disposition", "inline")
Response.OutputStream.Write(FilledBuffer, 0, FilledBuffer.Length)
Response.OutputStream.Flush()
Response.OutputStream.Close()
Response.End()
where FilledBuffer (a byte array) is valid html like:
<!DOCTYPE html>
<html>
<head>
<title>My Page</title>
</head>
<body>
<div>content</div>
</body>
</html>
When I view this in IE8+ it renders an as html page, however in Chrome it displays the html as text. My first thought is the MIME type but text/HTML is correct for html, so I am at a loss.
I must be missing something very simple here...or the internet would not work...
In fiddler the request between a standard aspx page that renders html and the above non-working page are identical, specifically:
GET http://localhost:1202/test.aspx HTTP/1.1
Host: localhost:1202
Connection: keep-alive
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36
Referer: http://localhost:1202/Mypage.aspx
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8
The byte array used by the response stream was created with unicode encoding, thus the output was indeed unicode. Interesting that IE does not seem to care about this but Chrome recognized this was not html and simply rendered the page as text. The giveaway unicode double charter width was not displayed by Chrome and inspecting page source showed a perfectly valid looking html file. It was not until inspection in fiddler that the unicode was detected which lead to the discovery of the incorrect conversion.
Arabic user data that was submitted from a website form occasionally ends up Mojibake in our database. A user would type something like:
الإعلان العالمى لحقوق الإنسان
in an input form and the post is received by a server and stored in a database. When we retrieve the message from the database, it reads:
الإعلان العالمى Ù„Øقوق الإنسان
The form is in an embedded iframe page with these tags:
<!DOCTYPE HTML>
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type" />
<!-- other header elements -->
</head>
<body>
<form accept-charset="utf-8" action="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="post">
<!-- other body elements -->
</body>
</html>
A post generate these request headers
Accept */*
Accept-Encoding gzip, deflate
Accept-Language en-US,en;q=0.5
Cache-Control no-cache
Connection keep-alive
Content-Length 543
Content-Type application/x-www-form-urlencoded; charset=UTF-8
Host www.salesforce.com
Origin [ -- redacted -- ]
Pragma no-cache
Referer [ -- redacted -- ]
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:28.0) Gecko/20100101 Firefox/28.0 FirePHP/0.7.4
x-insight activate
And receives these response headers
HTTP/1.1 200 OK
Date: Fri, 25 Apr 2014 09:15:49 GMT
Cache-Control: private
Content-Type: text/html;charset=UTF-8
Transfer-Encoding: chunked
I have no control over the server configuration of the machine serving the form or the server processing the form data.
Is there anything more I can do in the page markup that can prevent the problem? Are there known user agents which would ignore the accept-charset attribute?
Since the character scramble only happens occasionally, what is the best way to try and replicate / isolate the problem?
Thanks!
I have a problem with a website, where sometimes only the HTML text is displayed in the browser window, instead of the rendered HTML page. This happens sometimes in all browsers.
Example URL:
http://www.starkl.at/view/p-1258/Newsletter---Gartentipp/
The HTTP request headers from IE9 are (Cookies are not shown):
GET http://www.starkl.at/view/p-1258/Newsletter---Gartentipp/ HTTP/1.1
Accept: text/html, application/xhtml+xml, */*
Referer: http://www.starkl.at/view/p-1931/Service/
Accept-Language: de-AT
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
DNT: 1
Host: www.starkl.at
Pragma: no-cache
The HTTP response headers are:
HTTP/1.1 200 OK
Date: Wed, 19 Sep 2012 07:43:49 GMT
Cache-Control: no-cache, no-store, must-revalidate, proxy-revalidate
Content-Type: text/html;charset=UTF-8
Content-Length: 21160
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Also the content length (in bytes) seems to match.
It's a Java 6/7 application running on a Tomcat 6/7, with an additional httpd 2.2.x in front.
Any idea what the problem could be????
Thanks in advance!
If the browser writes the code and not renders it is because it's being told to do so, probably your app is returning html encoded in a way that browser thinks it's plain text.
Open tools, options, email, email options, then uncheck "Read all standard mail in plain text." This is for Outlook 2003 so your version, if not 2003, might be slightly different.
I am using CGI::Application with UTF-8 data.
In the HTML have I set encoding to UTF-8 like so
<!DOCTYPE html>
<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
but the output is treated as latin1, as special characters are displayed as 2 characters.
Page Info in Firefox says the page is encoded with ISO-8859-1 despite the HTML header.
I have only been able to find these two posts about the problem, but they are old and very complicated.
Anyone that have solved this problem?
Update: Here are the HTTP header from FireBug.
Response Headers
Date Tue, 26 Apr 2011 09:53:24 GMT
Server Apache/2.2.3 (CentOS)
Connection close
Transfer-Encoding chunked
Content-Type text/html; charset=ISO-8859-1
Request Headers
Host example.com
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:2.0) Gecko/20100101 Firefox/4.0
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language en-gb,en;q=0.5
Accept-Encoding gzip, deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 115
Connection keep-alive
I noticed that if I force UTF-8 by FireFox->Web Developer->Character Encoding->Unicode (UTF-8), if looks correct.
Your HTTP headers:
Content-Type text/html; charset=ISO-8859-1
… claim the document is encoded as Latin 1. Real HTTP headers take priority over HTML <meta> data.
$webapp->header_add(-type => 'text/html; charset=UTF-8');
… should do the job if I'm reading the documentation correctly.