Commit 143888e8 authored by Erick Hitter's avatar Erick Hitter

Add caching

parent dae097e7
......@@ -2,6 +2,8 @@
// Libraries and other setup
var express = require( 'express' );
var apicache = require( 'apicache' );
var cache = apicache.middleware;
var wpapi = require( 'wpapi' );
var handlebars = require( 'express-handlebars' );
var app = express();
......@@ -20,8 +22,8 @@ var domains = {
'i.ethitter.com': 'https://i.ethitter.com/'
};
// Rendering
app.get( '/', function( req, res ) {
// Homepage
app.get( '/', cache( '30 minutes' ), function( req, res ) {
res.render( 'index', { data: { domains: domains } } );
} );
......@@ -31,7 +33,7 @@ app.get( '/api', function( req, res ) {
} );
// Render the domain's latest post
app.get( '/api/:domain', function( req, res ) {
app.get( '/api/:domain', cache( '5 minutes' ), function( req, res ) {
// For convenience
var domain = req.params.domain;
......
......@@ -16,7 +16,8 @@
"dependencies": {
"express": "*",
"wpapi": "*",
"express-handlebars": "*"
"express-handlebars": "*",
"apicache": "*"
},
"repository": {
"type": "git",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment