Apache sets default Response charset

I’ve been currently working on a application that should render charset ISO-8859-1 to the browser.  So I’ve added a following meta tag to HTML document header.

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

For some reason when rendering the page,  it always makes some characters broken or not been recognised. I’ve spend a good few hours to debug this situation thought it was due to some issue with application itself how it handles encoding.

Thanks to built-in browser “Inspect Element” tool, I’ve managed to crack down the root issue. It was causing this issue due to Response ContentType set to use charset UTF-8.

Content-Type:text/html; charset=utf-8

Application wasn’t setting ContentType charset in Response, Then where did this charset came from ?. HTML header meta tag wasn’t taking a effect in this case. It has overridden by Response ContentType charset.

-This is the time Apache took my attention.

It turned out that Apache was automatically sets AddDefaultCharset config directive to be UTF-8. It was automatically added to /etc/httpd/conf/httpd.conf by Default Installation.

AddDefaultCharset UTF-8

I’ve commented out  AddDefaultCharset directive form Apache config and reloaded Apache, it worked as expected.

I guess if you wanted to control encoding by application level then you should AddDefaultCharset Off or remove it from Apache config.

Hope this helps to solve unexpected encoding issues due to Apache config.

Backup MySQL to Google Drive

I always had this issue when i started to working on new projects where do i keep my MySQL backup data, if i keep backup data same server as my application running it’ll soon consume all disk space just for backup data. So I wanted to find a solution for this.

 

Cloud Hosting providers tend to charge extra fees if you want to enable automated backups or there might be terms which you don’t like. I think most of startups/individual projects don’t want to spend too much money on their backups or may be funding might be limited.

I’ve look around for cheap but reliable service for this, The solution I’ve came across is to use Google Drive as my backup storage which has fair prices to increase storage(if needed, otherwise stick to free storage limit), reliable and highly available. Also there’s a well documented API available for this service.

I’ve used python for all background work for this task, then it’ll upload file straight to Google Drive.

Installation and help guide available on https://github.com/KasunDon/google-drive-mysql-backup

Feel free to give me a feedback or report any issues.