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