Improve caching

pull/20/head
Joe Biellik 5 years ago
parent b4ab5d7ff3
commit 6f4adbfc4f

@ -1,10 +1,12 @@
const router = require('koa-router')(); const router = require('koa-router')();
const conditional = require('koa-conditional-get')();
const etag = require('koa-etag')();
const config = require('config'); const config = require('config');
const pastes = require('./controllers/pastes'); const pastes = require('./controllers/pastes');
router router
.get('/', async (ctx) => { .get('/', conditional, etag, async (ctx) => {
ctx.set('Cache-Control', 'no-cache'); ctx.set('Cache-Control', 'public');
await ctx.render('index', { await ctx.render('index', {
pretty: config.prettyHtml, pretty: config.prettyHtml,
@ -15,6 +17,6 @@ router
}); });
}) })
.post('/', pastes.create) .post('/', pastes.create)
.get('/:id', require('koa-conditional-get')(), require('koa-etag')(), pastes.view); .get('/:id', conditional, etag, pastes.view);
module.exports = router; module.exports = router;

Loading…
Cancel
Save