package compositions; import play.libs.F; import play.mvc.Action; import play.mvc.Http.Response; import play.mvc.Http.Context; import play.mvc.Result; import play.mvc.With; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; public class NoCacheComposition { @With(NoCacheAction.class) @Target({ElementType.TYPE,ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) public @interface NoCache { String value() default "*"; } public static class NoCacheAction extends Action<NoCache>{ public F.Promise<Result> call(Context context) throws Throwable { Response response = context.response(); response.setHeader("Cache-Control","no-cache, no-store, must-revalidate"); response.setHeader("Pragma","no-cache"); response.setHeader("Expires","0"); return delegate.call(context); } } }