Improve caching

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

@ -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;

Loading…
Cancel
Save