I'm confused.
If I point by browser (Chrome or Safari on OSX) to this web site, it shows all the SVG perfectly:
http://emacsformacosx.com/
Now, if I view source on that page, copy it, and paste it into a new HTML document on my desktop, then view that with either browser, I get no SVG at all.
Why the difference?
Why does SVG work on the web site, but not in the local HTML file?
Thanks!
You renamed it to HTML, and the browser assumes html content.. while the page is text/xml ..
if you rename it to .xml and open it, you will see it just fine..
The HTTP response header information causes the browser to interpret the information as XML:
HTTP/1.1 200 OK
Date: Sun, 21 Feb 2010 02:32:02 GMT
Server: Apache/2.2.14 (Debian)
Vary: Accept-Encoding
Transfer-Encoding: chunked
Content-Type: text/xml; charset=UTF-8
You see, the server that served up the page was smart enough to detect that this was an XML document, and told the browser. When you load the file from disk, your browser may not be smart enough to do this, and tend to rely on the file's extension to supply this information.
You could try inserting the following into the <head> element:
<meta http-equiv="Content-Type" content="text/xml; charset=UTF-8" />
You see what I did there? It's just a mirror of the HTTP response header that would have specified the document type and encoding.
The purpose of this tag is to make browsers think, "Hey, the server is telling me that this document is HTML, but the document is telling me it's XML. The document probably knows better than the server, so I'll trust it... ::interprets as XML::"
Related
I have an old web site in French tha I want to preserve and whose html files were encoded in iso-8859-1. All html files included
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
in the <head> element, however the host of my website changed something in the configuration an now pages are sent from their server with an HTTP header including
content-type: text/html; charset=UTF-8
and unfortunately someone decided this would override the <meta> information.
Do I have to trans-code all my html files to UTF-8 or is there a faster solution?
Update
In fact the charset was added to the http header's content-type field only for html content issued by php, not for pure html files. I'll put the solution I adopted as an answer.
Your options:
Transcode the files
Persuade whomever changed the server configuration to change it again
Change servers
Run all every request through a server side script which outputs a different Content-Type header and then outputs the HTML (which accounting for cache-control headers)
Took me a while to realize the problem occurs only for .php files. The fix I chose is the following: I added the line
ini_set('default_charset', NULL);
at the beginning of every php files. A bit tedious but seems reasonable to me.
I need to disable caching for single files in all browsers.
I have a website that generates small video clips. There is a preview stage where the results can be watched.
An mp4 called preview.mp4 is displayed. When the user goes back, edits the video and wants to preview it again, the old preview.mp4 is being displayed even though the file on the server is changed.
How can I prevent the caching of this video file? Or what are the other ways to fix it?
Note: it's a single page application so I don't reload any HTML files. Only PHP content. Hence the headers I set, are not useful in this scenario:
<meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
<meta http-equiv="cache-control" content="no-store" />
Thanks.
It's not the web page itself you should be concerned about, but the mp4 file which is downloaded and cached separately.
Ensure the response headers of the mp4 file prevent browser caching.
Cache-Control: no-cache
Hence the headers I set, are not useful in this scenario:
<meta http-equiv="cache-control" content="no-store" />
There problem here is that those are not headers.
They are HTML elements (which are part of the HTML document, which is the body of the HTTP response) which attempt to be equivalent to HTTP headers … and fail.
You need to set real HTTP headers, and you need to send them with the video file (rather than the HTML document).
The specifics of how you do that will depend on the HTTP server you use.
Further reading:
Caching in the HTTP specification
Caching Tutorial for Web Authors and Webmasters
Caching Guide in the Apache HTTPD manual
How to Modify the Cache-Control HTTP Header When You Use IIS
Try adding a cache key
preview.mp4?cachekey=randNum
Where randNum can be a timestamp or you use a random number generator to generate randNum.
<h1>Wörterbuch</h1>
This is a very simple (generated by Zotero) html file and it is UTF-8 coded.
But firefox is not able to handle it correct.
When viewing the source of the opened html file in firefox it looks like that.
<h1>Wörterbuch</h1>
My last touch of HTML is from the beginning of the 90's. This file is UTF-8 so firefox should know itself how to handle the ö their. But it doesn't so I need something in the header, right?
What information does firefox need here?
This work well with Opera.
Make sure your HTTP server is sending the correct HTTP header to identify the encoding of the document:
Content-Type: text/html; charset=utf-8
As a fallback, add the <meta> tag to the document's <head>:
<meta charset="utf-8">
In an effort to learn more about font rendering/encoding I'm more curious as to why when I copy and paste the emojis 😇🐵🙈 into a blank <html> page and simply save the .html file locally on my machine, or even start a local php server and serve files with the above emojis in there, they either show up as some weird characters (😇ðŸµðŸ™ˆ) or blank, respectively. Yet I know that when I type them straight into this very stack overflow ask textarea, they will render correctly in my browser, and be displayed as intended when viewing this page.
My understanding is that since mac osx now ships with the correct emoji fonts, they should be rendered as just that. So where is the disconnect between the HTML page you're looking at right now, and the local one I saved on my computer?
And recommended reading would be appreciated! :) errr.... 😀
When a web server sends a file to a browser, it will send a set of HTTP headers as well, relaying information about the content type, caching, etc. The content-type header also informs the browser which encoding was used:
Content-Type: text/html; charset=utf-8
If your open that file locally then your browser only gets the file and it has to guess the encoding. You can declare the encoding in the HTML head:
<meta charset="utf-8">
I have an HTML document that is on a local server (not a webserver, if that's important). Sometimes, after updating some files, I go to visit the HTML document and it is not updated. However, if I try to refresh the page, the content then updates.
I'm not sure why this is occurring considering that I am opening the page anyway after update, so it should have the latest values then.
The issue is that browser is caching the HTML document it self. It is fine for static pages, where data remains constant
but as you stated that content of the page is dynamic, you can do 2 things
Add expiration header for document via server side code. This ensures that when ever user tries to access your page, the browser always sends a request to server and ignores local cache. Some of the headers you need to set
Cache-Control : no-cache, no-store, must-revalidate
Expires : -1
Pragma : no-cache
Add expiration via meta tags
<meta http-equiv="expires" content="Fri,31 Dec 2010 11:59:59 GMT" />
<meta http-equiv="cache-control" content="no-cache">
This should be kept under <head> tag