Archive

Archive for February, 2009

IPv6 support still lacking

February 17th, 2009

I was playing HE.net’s IPv6 certification test last night. And I got stucked on last step, adding an AAAA tld glue record for my domain. Unfortuantely the domain registrar I am using, 1&1 AG,  does not support AAAA record in their system.

Here is the email I got this afternoon,

Thank you for contacting us. Unfortunately, our system does not support AAAA record. Our system only supports modifying the DNS, A-record & Mx-Records as well as CNAME. If you have any further questions please do not hesitate to contact us.

– Sincerely,
xxxxxxx xxxxxxx
Technical Support
1&1 Internet

The test from he.net is not easy. Here is the list of softwares and services I used last night through trial and error.

  1. The first test is browsing an IPv6 website from he.net. I tried many methods. On my local Windows machine, I can ping -6 ipv6 address, I can copy and paste ipv6 into browser. But browser just refused to connect to remote host by ipv6 hostname.  I tried to build ipv6 enabled Lynx on a linux machine, which also failed. Because none of above worked, I had to cheat on this step by using http://ipv6.he.net.ipv4.sixxs.org/.   
  2. Run a webserver on IPv6 address. Very simple, I added an ipv6 address into my webserver, Cherokee, and everything worked as they should.  
  3. Run a mail server on IPv6 address. Postfix, the mail server I am currently using, supports IPv6 natively. Simply add inet_protocols = all into main.cf, postfix will start listerning on IPv6 socket. First email unfortunately failed due to dkim-milter refused connection from ipv6 address. After disabling, 2nd email passed through.  
  4. Have a RDNS record for my MX record. I am using ipv6 patched tinydns. NS and SOA record for my /48 prefix to tinydns are required to get response for PTR record. It took me a while to figure that out. Patched tinydns has a utility add-host6 to handle record for both forward and reverse dns but ns and soa need to be added manually.  
  5. Run DNS server natively on IPv6. Even though tinydns is listerning on IPv6 address and my local dig show correct response. But he.net did not accept it for unknown reason. So I installed Bind9, and everything just worked in less than 5 minutes.  
  6. Add an AAAA glue record to TLD nameserver. 1&1 AG does not support it as I said at beginning of the post. I am transferring my domain to GKG.net, hope they works, and I will update this post once I finish this step.  Here is a list of domain registrars supporting ipv6 glue.

So here is my test result.  

I am using dnsmadeeasy for my DNS, but they do not support IPv6 in any means. My VPS providor, Linode LLC, supports AAAA record in nameserver, but no ipv6 PTR record and no native IPv6 connection, no ipv6 dns servers.

Bookmark and Share  
 

Yejun Linux , , , , , ,

How to use SimpleCDN with WordPress

February 15th, 2009

Update 2/24/2009: This method is deprecated. I wrote a plugin to rewite urls.
Update again: SimpleCDN is slower comparing to CloudFront, I moved all my link to CF. If you have problem copying files to S3, you can read this post.

WordPress is my favorite bloging software, with many builtin features and powerful plugins. WordPress.com, the blogging platform by automattic, has been using CDN for a long time. However there is no public available solution to make self hosted WordPress to use a CDN as well. Fortunately the php code itself is very clean to read, so it took me about 5 minutes to find where I should modify to fully integrate my new CDN address.

Before you proceed, please read my previous posts on how to use CNAME with SimpleCDN and how to process javascript and css files for WordPress. Make sure your SimpleCDN’s CNAME and bucket working properly. I used a mirror bucket which points to my blog address, that is probably the simplest way to mirror your static assets. And use ‘-s1′ pre-url to insure client side cache working, because SimpleCDN does not use 304 not modified http header at all. I used bucket name ’s.mudy.info’ for my own blog.

Once your DNS full propagated, open your favorite text editor open following 3 files.

wp-includes/class.wp-scripts.php‘: near line 75, change

$src = $this->base_url . $src;

to

$src = 'http://yourcdnbucketname' . $src;

There is no trailing slash after your bucketname. If you want to make sure client browser always use cached version, you can also comments out the following line.

// $src = add_query_arg('ver', $ver, $src);

But this change may break WordPress upgrade.

wp-include/class.wp-styles.php‘: near line 79, do the same change as above.

wp-include/theme.php‘: near line 504, change

return apply_filters('theme_root_uri', content_url('themes'), get_option('siteurl'));

to

return 'http://yourcdnbucketname/wp-content/themes';

That’s it. Now clean your cache and test your blog.

Bookmark and Share  
 

Yejun Web , , ,

Optimize WordPress javascript placement

February 13th, 2009

YSlow rule 6: Put JS at the bottom. This is a very simple rule, but it has noticeable improvement on actual page loading time. Because javascript in head will block both page elements loading and rendering. The placement of javascript in WordPress 2.7.1 is hard coded to be placed in html head, because most ajax plugin would expect javascript library to be fully loaded before page load. If you use WordPress without any fancy ajax related plugins, it is very possible to load javascript at bottom of every page without breaking any blog function. I also tested it with Lightbox 2 without any noticeable problems. The measurable page loading time difference is near half a second when browser cache is empty. Before you proceed to make any change to WordPress php files, I would recommend you to do a full backup of database and related php files. Now open ‘wp-includes/default-filters.php‘, search wp_print_scripts. Near line 184, you should find,

add_action('wp_head', 'wp_print_scripts');

Change this to

add_action('wp_footer', 'wp_print_scripts');

Clear your WordPress page cache and test your WordPress. Ideally one could write a plugin hooking into filter ‘print_scripts_array’ to remove plugins from html head conditionally. But I have not found one yet. There are a lot other methods to safely speedup javascript loading in html header. Unfortunately they are not very easily implemented and cross different browsers. Steve, author of Yslow had a post and talk explaining the whole situation.

Bookmark and Share  
 

Yejun Web , , , , ,

One line script to minify js css directory using yuicompressor

February 11th, 2009

The default installation of WordPress use full version of css and javascript library. In order to minify all of these files, I wrote this bash script to minify all of them. There will be no progress bar while minifying, so be patient.

cd wordpress
find -H . -type f -writable  \( -name \*.css -o -name \*.js \)  \
-exec sh -c "yuicompressor {} -o /tmp/yui.tmp && mv /tmp/yui.tmp {}" \;

This will only work under POSIX system.
Findutils should be included in most popular Linux distros.
Yuicompressor can be downloaded from here.

Bookmark and Share  
 

Yejun Linux , , , , , , , ,

SimpleCDN CNAME Confusion

February 9th, 2009

I am using SimpleCDN to serve some static scripts and images of WordPress on my website.

Not like AWS CloudFront, Amazon’s CDN service, which only allows expiration date carried from S3 file meta. SimpleCDN supports fine tuning Expiration, P3P and gzip encoding through something called Pre-URL. Which look like these

http://s.mudy.info.simplecdn.net/
http://s.mudy.info-s1.simplecdn.net/
http://s.mudy.info-e7.simplecdn.net/

Here ‘-s1′ means special 1 with expire and gzip; ‘-e7′ means 10 years expire without gzip. And a lot more with different combo effects.

SimpleCDN also supports CNAME to any of these urls. Because there is not a lot document on how to use simplecdn. I mistakenly CNAMEed ’s.mudy.info’ to the first URL

s.mudy.info.simplecdn.net

Run my website through Yslow, I got a lot F score due to lack of expire headers and non-gzip on static files. I realize I have to use these different Pre-URLs in order to get http headers, so I substitute ’s.mudy.info’ in WordPress with ’s.mudy.info-s1.simplecdn.net’ or ’s.mudy.info-e7.simplecdn.net’. Originally very simple urls’ become long and urgly.

Due to some DNS setting error, I accidentally pinged 2 different SimpleCDN pre-urls. The results are 2 different IPs. I reallized I made another mistake today, these pre-urls are supposed to be used as CNAME to get different http headers and gzip encoding, because these hostname all has their own IPs. A quick testing I CNAME ’s.mudy.info’ to

s.mudy.info-s1.simplecdn.net

which gives nicely gzipped files with correct expiration settings.

This design is what I initially did not expect. Because traditional CDN usually use HTTP hostname to distinguish objects, so I normally would think I have to use different hostnames. However SimpleCDN use anycast , so they use same IP block on on all edge servers, which make it possible to use different IP addresses to distinguish requests.

Bookmark and Share  
 

Yejun Web , ,

Using tinydns wildcards with cautions

February 9th, 2009

Tinydns support wildcards. However I just made a mistake make my own website inaccessible.

I was pointing all subdomains to a single host including this website.

C*.mudy.info:nw.mudy.info:1200

It worked perfect fine, until today I encounter a website which requires myn...@blog.mudy.info to verify ownership. I know it should just working without any further settings, however to be nice I added an additional mx record to my Tinydns to explicitly indicates the mail host of blog.mudy.info

@blog.mudy.info::nw.mudy.info.:5:1200

After that my website become inaccessible. Apparently tinydns will stop looking into data once a matching name found, even though the record type does not match and there are better matching wildcards.

To fix this, I added another explicit A record.

+blog.mudy.info:66.246.138.44:1200

CNAME record will work as well.

Bookmark and Share  
 

Yejun Linux , , , ,