Make web apps act more native

With a simple trick you can make a web-based app look and act more native on an iPhone or iPod Touch.

Adding the following tags to your <HEAD> will make your application open in full screen and hide Safari’s toolbars. In addition, if you add it to your home screen, it will appear to open without Safari and no page will be added to Safari.

<meta name="viewport" id="viewport" content="width=device-width,user-scalable=no,minimum-scale=1.0,maximum-scale=1.0" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />


The following tags, which should also be added to <HEAD>, will provide an icon for the home screen and a splash screen to be displayed when it opens.

<link rel="apple-touch-icon" href="http://example.com/webclip.png" />
<link rel="apple-touch-startup-image" href="http://example.com/startup.png" />


The first application I’ve seen which uses this trick is Fever.

Server crash

As you’ve probably heard, wordpress.com was down today, which means ICanHasCheezburger, FailBlog and other related sites were down. Since my feed proxy script used for the iPhone app accesses those sites, it eventually ended up crashing my entire server.

A support person at Dreamhost explained:

Yeah, the issue was likely that your PHP scripts were hanging due to not
getting a response, which then caused the requests to build up and
overload the running PHP processes.

Nginx update

After running Nginx for a day everything seems stable. The memory usage is much lower – I was able to reduce my PS from 458M to 304M. The sites seem faster & more responsive, and memory usage remains pretty much constant rather than fluctuating based on the number of connections, as it did with Apache.

Screen shot 2010-01-29 at 9.18.15 PM.png

Using Nginx at DreamHost

All of my sites are now running Nginx rather than Apache, which has several major advantages. Apache uses a separate process for each connection, so if you have a very busy site with lots of simultaneous connections it can use a huge amount of memory. Nginx, on the other hand, uses one worker process with a fixed number of CGI processes no matter how many connections it’s serving.

As you can see from my resource chart, the memory usage dropped dramatically when I switched over to Nginx.

Screen shot 2010-01-28 at 7.31.50 PM.png

Nginx has a few drawbacks, however. It doesn’t support Subversion or WebDAV, so I first had to move my Subversion repositories off my virtual private server. I ended up moving them to ProjectLocker. Most importantly, Nginx doesn’t use a .htaccess file. Instead, it uses its own configuration files, which DreamHost documents here.

Basically you need to create a nginx folder in your home directory, and make a subdirectory for each domain, for example ~/nginx/mcdevzone.com, and create a configuration file, which can be named anything. The syntax is different than .htaccess, although it has many of the same capabilities such as access control or rewriting URLs.

For a WordPress site, all you need is this:

#######################
# Permalinks

if (!-e $request_filename) {
  rewrite ^.*$ /index.php last;
}

DreamHost provides many more examples on their Wiki page, and you can find even more at the official Nginx site.

One important rule you should add to your config file, which DreamHost leaves out, is this one which will prevent users from viewing your .htaccess file, if you still have one.

location ~ /\.ht {
    deny  all;
}

I ran into a few gotchas, but once I figured them out I was able to get everything running smoothly. According to DreamHost’s documentation, the site-wide Nginx configuration file is at /dh/nginx/servers/httpd-psXXXXXX/nginx.conf, but I found that it didn’t exist, at least on my server. Instead it was named nginx.conf.pushing, so as a result Nginx refused to start. Once I renamed it, I was able to start nginx. You WILL need to have an admin user on your private server in order to access that file and restart nginx.

UPDATE: The problem I ran into with the missing config file was because the update didn’t finish properly for some reason.

DreamHost’s older virtual private servers don’t support Nginx, so if you want to use it, you may have to request to have your PS moved to a newer system.

If you have a very busy site, Nginx can help you deal with the load, so it’s worth checking out. Several major sites including WordPress.com, Hulu, and Github are using Nginx, so it’s definitely production quality.

Server Change

I’m having DreamHost move my private server to a newer system which will allow me to use Nginx instead of Apache, which should improve the speed and allow more connections.

This means that all of my sites may be down for an hour or so in the next few days and during that time the I Can Has Cheezburger app WILL NOT WORK, since it uses a feed proxy hosted on that server. After the change and after I switch the PS to Nginx, it should run much faster.

If no problems arise when I switch to Nginx, it will let my sites handle many more requests than Apache.

By signing up for DreamHost web hosting here you can help pay my hosting costs, which will let me increase the memory of my private server, and in turn make it even faster.

New Webhost

If you’re seeing this, the DNS is resolving to our new location at DreamHost.

When I had all of my domains hosted at MediaTemple, I was always very close to and often exceeded the monthly 1000 GPU limit.

Although MacMegasite is a pretty standard WordPress site without any plugins that hog processor time, it gets a lot of traffic and the database is pretty huge due to the number of posts. Even with WP-Super-Cache, it averaged over 30 GPU per day, which easily put it over the limit, not counting this site & WorldBeatPlanet.

A few weeks ago I moved MacMegasite to DreamHost, where I’m also hosting the feed proxy used by the latest ICHC app. After the move, I found that MacMegasite ran a lot faster than it did at MediaTemple, which I found to be getting a lot slower lately.

One reason I prefer DreamHost to MediaTemple is because their Panel API lets you control your virtual private server from an iPhone app, among other things. With DreamHost I can change the memory size or reboot my VPS at any time. DreamHost also lets you create a separate user for each domain or group of domains, so it’s a lot easier to give someone access only to a particular domain than at MediaTemple, which puts all of the domains under a single user.

DreamHost Management App
DreamHost App

DreamHost had some problems a few years ago, but they definitely got their act together and they now seem reliable. MediaTemple, on the other hand, seems to have become extremely slow with frequent server outages.

Hosting Dreams

I’m considering moving this site and WorldBeatPlanet back to DreamHost. These are the only two sites I currently have hosted at MediaTemple. I haven’t had any major problems here, but I always have the threat of GPU overage charges since with all 3 sites hosted here, I was dangerously close to the 1000/month GPU limit. I’d rather not have to pay for two hosting accounts when I can do everything with one.

I recently moved MacMegasite to DreamHost after I got a warning that I would exceed my GPU quota by about 300 (which ended up being only $3.80). I had kept my DreamHost account open all this time and I was still hosting a few smaller sites there.

Over the last year or so, DreamHost has definitely got their act together after a rocky period. I’m very happy with DreamHost’s speed – most of the time MacMegasite loads a lot faster at DreamHost than this site does at MediaTemple.

Since I’m using a Virtual Private Server at DreamHost, I can change the memory size at any time if it’s getting a lot of traffic. It can end up costing more, but I like being in control of the cost & performance rather than having a fixed limit. Usually my referrals pay for the basic hosting account so I only pay for the virtual server.

DreamHost also has a panel API with several iPhone applications available that can monitor and adjust the virtual server, or do other administrative tasks.

Another thing I prefer about DreamHost is being able to spread my domains among multiple users, rather than having all of them under a single user as MediaTemple does, which makes it a lot easier to give a user access only to certain domains.

MacMegasite is changing hosts

I’m moving MacMegasite back to DreamHost, after I got an email from MediaTemple warning of a large GPU overage of over 300 GPUs (which is around $30). The site should be down for a few hours, but for now you can see it at macmegasite.dreamhosters.com.

According to MediaTemple’s GPU usage report, the biggest offender is macmegasite.com/feed, which is being redirected to FeedBurner using a plugin, with 150433 hits for a total of 218.4496 (22% of the total).

WordPress for iPhone 2

WordPress for iPhone 2 is now available in the app store! Although it’s free, it’s a separate application, not an update to the original WordPress app, so you’ll have to download it from the app store.

The user interface has been redesigned and it’s really beautiful. A set of tabs makes it easy to switch between managing comments, posts, and pages. The comment screen now shows Gravatars and author URLs.

Overall, the application feels a lot more polished and more pleasant to use than WordPress for iPhone 1.x.

photo_2.jpg

 

photo.jpg