Skip to content

Instantly share code, notes, and snippets.

@timyates
Created September 25, 2014 13:14
Show Gist options
  • Save timyates/f2ac8f8c7bfa4f728c2e to your computer and use it in GitHub Desktop.
Save timyates/f2ac8f8c7bfa4f728c2e to your computer and use it in GitHub Desktop.
Cache control in Ratpack with Java
chain(context -> {
handler(ctx -> {
ctx.getResponse().getHeaders().set("Pragma", "No-cache");
ctx.getResponse().getHeaders().set("Cache-Control", "no-cache,no-store,max-age=0");
ctx.getResponse().getHeaders().setDate("Expires", new Date(LocalDate.ofEpochDay(0).atStartOfDay().toInstant(ZoneOffset.UTC).toEpochMilli()));
ctx.next();
});
assets("public");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment