Is AddDefaultCharset UTF-8 in .htaccess safe?

Very long story, but I had a problem with my site where there would be a white white page flashing between any page / link links on my site. Happened only in Firefox, and only in newer versions of Firefox (for example, it did not appear in version 3.6.x).

After comparing the response headers from two different servers, a site served from a different server didn't have this problem - I noticed that its response header had this:

Content-Type text/html; charset=UTF-8

      

My regular server that had the problem had this in the response header:

Content-type text/html

      

So, I added this line to my .htaccess and the problem went away:

AddDefaultCharset UTF-8

      

My questions:

  • What is a Content-Type that has no charset specified that could cause Firefox to blink (like 10 milliseconds) an entire blank white screen between pages on my site?

  • Now that I've fixed the problem, is my fix "ok"? Is it safe or does it have any high chance of hacking something else?

My quick testing showed no problem, but not knowing what side effects it might cause, or the reason it fixed my page forwarding issue bothers me.

+3


source to share


1 answer


I am assuming that your site is mainly serving English content, and since utf-8 is compatible with most English character encodings, I would say that this method is pretty safe. If not, you need to make the appropriate changes for this content.

By the way, there is also a default global character set configuration for most HTTP servers, which is theoretically more efficient than .htaccess settings. And in most web applications written in PHP, Java, whatever the language it may be, it should be best practice for the application itself to clearly state what encoding it uses.



For the flashfox element, in my past browser development experience, the browser needs to auto-detect the encoding if it is not specified in the response headers. So, if the original intended encoding is different from the one that was detected, the browser needs to forcefully reschedule the page. Just a rough guess, for a real reason, I think the firefox mailing list should be the best one to go.

+3


source







All Articles