X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=wicket%2Fcomponents%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fwicket%2Fpage%2FDisableCachingBehavior.java;fp=wicket%2Fcomponents%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fwicket%2Fpage%2FDisableCachingBehavior.java;h=04003a2c4769b4d0a4a740e904f39d1349db62be;hb=7e7d1f6f67766d5998d4631cffadb79da06a0acd;hp=0000000000000000000000000000000000000000;hpb=8e865a37b331adac21be54a9fbbc5bec1585d925;p=utils diff --git a/wicket/components/src/main/java/org/wamblee/wicket/page/DisableCachingBehavior.java b/wicket/components/src/main/java/org/wamblee/wicket/page/DisableCachingBehavior.java new file mode 100644 index 00000000..04003a2c --- /dev/null +++ b/wicket/components/src/main/java/org/wamblee/wicket/page/DisableCachingBehavior.java @@ -0,0 +1,45 @@ +/* + * Copyright 2005-2010 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.wamblee.wicket.page; + +import org.apache.wicket.markup.html.WebPage; +import org.apache.wicket.protocol.http.WebResponse; + +/** + *

+ * Behavior to disable browser caching. This also means that the page + * automatically expires the first time after it is rendered. + *

+ * + *

+ * Important: To make sure that form data cannot be submitted twice for the same + * data using the back button, it is still necessary to explicitly call + * getPage().getPageMap().remove(getPage()); in the + * onSubmit callback of the form. + *

+ * + * @author Erik Brakkee + * + */ +public class DisableCachingBehavior extends ExpirePageImmediatelyBehavior { + + @Override + public void setHeaders(WebPage aPage, WebResponse aResponse) { + aResponse.setHeader("Pragma", "no-cache"); + aResponse.setHeader("Cache-Control", + "no-cache, max-age=0, must-revalidate, no-store"); + } +}