Book Image

Advanced Express Web Application Development

By : Andrew Keig
Book Image

Advanced Express Web Application Development

By: Andrew Keig

Overview of this book

Building an Express application that is reliable, robust, maintainable, testable, and can scale beyond a single server requires a bit of extra thought and effort. Express applications that need to survive in a production environment will need to reach out to the Node ecosystem and beyond, for support.You will start by laying the foundations of your software development journey, as you drive-out features under test. You will move on quickly to expand on your existing knowledge, learning how to create a web API and a consuming client. You will then introduce a real-time element in your application.Following on from this, you will begin a process of incrementally improving your application as you tackle security, introduce SSL support, and how to handle security vulnerabilities. Next, the book will take you through the process of scaling and then decoupling your application. Finally, you will take a look at various ways you can improve your application's performance and reliability.
Table of Contents (14 chapters)
Advanced Express Web Application Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Favicon


Lets add a favicon to our application using the connect.favicon middleware. From a performance perspective, this has some value as we can cache it. Also, your browser will request a favicon even if one does not exist, and this can result in 404 errors being thrown. We will use the existing staticCache config value to set maxAge for the favicon. Let's edit the Express server, /vision-web/lib/express/index.js, and add the favicon middleware:

app.set('views', 'views');
app.use(express.favicon('public/components/vision/favicon.ico'), { maxAge: config.get('express:staticCache') });

Minification

We can improve page load time by minifying our static assets. We will minify our JavaScript and CSS files by installing the following two grunt tasks:

grunt-contrib-uglify: This allows you to minify JavaScript files:

npm install grunt-contrib-uglify --save-dev

grunt-contrib-cssmin: This allows you to minify CSS files:

npm install grunt-contrib-cssmin --save-dev

Let's add these minification tasks...