Note: This question is about my server configuration giving 504 timeouts.
I made a project here http://www.tryperl.com/ (requires auth with GitHub to sign in). Please be kind, I'm working on to learn Lamp(erl)
I used a
- Micro Instance (w/ free tier) Amazon EC2 server
- Amazon Linux, perl.
- I used the Dancer framework
- CGI configuration to host it.
- I have a virtual host conf in apache (with a sites-enabled folder and the conf file, and my site sits under /srv/www/tryperl.com/TryPerlApp/)
If you haven't guessed, it's a rudimentary IDE, you can write some basic perl script with print commands and run it and see the output. I'm using the Safe.pm module currently.
The Problem:
It usually takes forever to load. There are a number of JS files, half of which result in a 504. The site barely loads on the first go. Here is what firebug sees:

I'm a total linux/apache newbie here. What am I doing wrong? My config with mod_perl earlier behaved way better, so I'm sure it's not my server.
Is it the CGI configuration? Should I used nginx on the front for static files? Can I do that with my configuration?