Skip to content

Instantly share code, notes, and snippets.

@trezy
Created October 19, 2017 15:12
Show Gist options
  • Save trezy/8e6d3db8f5a54e8c33da4b487abe51bc to your computer and use it in GitHub Desktop.
Save trezy/8e6d3db8f5a54e8c33da4b487abe51bc to your computer and use it in GitHub Desktop.
// `ctx` is an object that Koa.js passes through its middleware, allowing the
// middleware to modify it as they see fit. `ctx.request` and `ctx.response` are
// objects that reflect the contents of the HTTP request and response,
// respectively
var oldEtag = ctx.request.headers['if-none-match']
var newEtag = ctx.response.headers['etag']
ctx.fresh = (oldEtag !== newEtag)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment