Skip to content

Commit

Permalink
feat(koa): implement static cache
Browse files Browse the repository at this point in the history
  • Loading branch information
kiki-le-singe committed Jan 9, 2017
1 parent c093939 commit 6c64e90
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/server/koa.prod.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import Koa from 'koa'
import compress from 'koa-compress'
import staticCache from 'koa-static-cache'
import _debug from 'debug'
import serve from 'koa-static'
import convert from 'koa-convert'

import handleRender from 'server/utils/render'
import projectConfig from '../../config'
import projectConfig, { paths } from '../../config'

const debug = _debug('app:server:prod')
const app = new Koa()
Expand All @@ -15,6 +17,10 @@ app.use(compress({
flush: require('zlib').Z_SYNC_FLUSH
}))

app.use(convert(staticCache(paths('staticDir'), {
maxAge: 365 * 24 * 60 * 60 // Add these files to caches for a year
})))

app.use(serve('static'))

// This is fired every time the server side receives a request
Expand Down

0 comments on commit 6c64e90

Please sign in to comment.