Skip to content

Commit

Permalink
Add cache control
Browse files Browse the repository at this point in the history
  • Loading branch information
chemicstry committed Jan 20, 2018
1 parent f276b5d commit a0629be
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
17 changes: 17 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const commandLineArgs = require('command-line-args');
const optionDefinitions = require('./options.js');
const getUsage = require('command-line-usage');
const express = require('express');
const cacheControl = require('express-cache-controller');
const moment = require('moment');
const path = require('path');
const fs = require('fs');
Expand Down Expand Up @@ -72,6 +73,12 @@ function SaveGraph()
}
setInterval(SaveGraph, options.graphLogInterval);

// Setup cache
app.use(cacheControl({
public: true,
maxAge: 60
}));

//FORCE SSL
app.use(function(req, res, next) {
if (req.headers['x-forwarded-proto'] === 'http') {
Expand All @@ -92,6 +99,11 @@ app.get('/networkgraph', function(req, res) {

// Create payment invoice
app.get('/getinvoice', function(req, res) {
// Disable cache
res.cacheControl = {
noCache: true
};

var value = parseInt(req.query.value);

if (!value || isNaN(value) || value < 1)
Expand Down Expand Up @@ -122,6 +134,11 @@ function isHexString(str)

// Reply with invoice status
app.get('/invoicestatus', function(req, res) {
// Disable cache
res.cacheControl = {
noCache: true
};

var rhash = req.query.rhash;

if (!isHexString(rhash) || rhash.length != 64)
Expand Down
19 changes: 19 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"command-line-args": "^5.0.1",
"command-line-usage": "^4.1.0",
"express": "^4.16.2",
"express-cache-controller": "^1.1.0",
"grpc": "^1.8.0",
"moment": "^2.20.1"
}
Expand Down

0 comments on commit a0629be

Please sign in to comment.