Local NodeJS development environment with Nginx

01 September 2010   0 comments   Javascript

Mind That Age!

This blog post is 8 years old! Most likely, its content is outdated. Especially if it's technical.

I'm brand spanking new to the node.js web application development. The framework I'm currently using is express which seems OK. So I've got an app that consists of 1 static HTML file, a lot of Javscript/CSS/image resources and some express GET and POST views that return small snippets of HTML. All data will be loaded with AJAX to avoid having to use any HTML templating on first load. What's cool about this is that it's soo fast! Everything except the JSON data can be loaded from an Nginx server.

At the moment I've got a light static HTML page that loads about 240Kb of Javascript and CSS (jQuery UI is big) and a couple of bytes of JSON data pulled from Node. As a little anal perfectionism I put an Nginx server in front so that Node doesn't have to serve any of the static files. To get that you have to have a Nginx site enabled that looks like this:

server {
   root /home/peterbe/task-calendar/static;
   location / {
     if (-f $request_filename) {
         add_header X-Static hit;
         access_log   off;
     }
     if (!-f $request_filename) {
         proxy_pass http://127.0.0.1:8000; # where Node is running
         add_header X-Static miss;
     }
   }
}

I think much of the fun of working with this app is that it's a delight to see it load in the browser without any sluggishness or delay. Lovely!

Comments

Your email will never ever be published


Related posts

Previous:
Musings about django.contrib.auth.models.User 28 August 2010
Next:
I just discovered wikiHow 08 September 2010
Related by Keyword:
How's My WiFi? 08 December 2017
Find static files defined in django-pipeline but not found 25 July 2017
Python slow-down of exception handling or condition checking 14 May 2015
How I stopped worrying about IO blocking Tornado 18 September 2012
Slides about Kwissle from yesterdays London Python Dojo 08 July 2011
Related by Text:
jQuery and Highslide JS 08 January 2008
I'm back! Peterbe.com has been renewed 05 June 2005
Anti-McCain propaganda videos 12 August 2008
Ever wondered how much $87 Billion is? 04 November 2003
Guake, not Yakuake or Yeahconsole 23 January 2010