[SYNCOPE-1272] Set browser cache duration to NONE for ResourceStreamRequestHandler
authorMarco Di Sabatino Di Diodoro <marco.disabatino@tirasa.net>
Mon, 12 Feb 2018 10:38:18 +0000 (11:38 +0100)
committerMarco Di Sabatino Di Diodoro <marco.disabatino@tirasa.net>
Mon, 12 Feb 2018 10:40:29 +0000 (11:40 +0100)
client/console/src/main/java/org/apache/syncope/client/console/pages/BasePage.java
client/console/src/main/java/org/apache/syncope/client/console/wicket/ajax/form/AbstractAjaxDownloadBehavior.java
client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/AjaxDownload.java

index 0cff36c..ebb14f2 100644 (file)
@@ -64,6 +64,7 @@ import org.apache.wicket.markup.html.list.ListView;
 import org.apache.wicket.request.handler.resource.ResourceStreamRequestHandler;
 import org.apache.wicket.request.mapper.parameter.PageParameters;
 import org.apache.wicket.request.resource.ContentDisposition;
+import org.apache.wicket.util.time.Duration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -135,6 +136,7 @@ public class BasePage extends WebPage implements IAjaxIndicatorAware {
                             ? SyncopeConsoleSession.get().getDomain() + "Content.xml"
                             : stream.getFilename());
                     rsrh.setContentDisposition(ContentDisposition.ATTACHMENT);
+                    rsrh.setCacheDuration(Duration.NONE);
 
                     getRequestCycle().scheduleRequestHandlerAfterCurrent(rsrh);
                 } catch (Exception e) {
index 9342c7d..004f7c8 100644 (file)
@@ -22,6 +22,7 @@ import org.apache.wicket.ajax.AjaxRequestTarget;
 import org.apache.wicket.behavior.AbstractAjaxBehavior;
 import org.apache.wicket.request.handler.resource.ResourceStreamRequestHandler;
 import org.apache.wicket.util.resource.IResourceStream;
+import org.apache.wicket.util.time.Duration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -45,7 +46,8 @@ public abstract class AbstractAjaxDownloadBehavior extends AbstractAjaxBehavior
     public void onRequest() {
         try {
             getComponent().getRequestCycle().scheduleRequestHandlerAfterCurrent(
-                    new ResourceStreamRequestHandler(getResourceStream(), getFileName()));
+                    new ResourceStreamRequestHandler(
+                            getResourceStream(), getFileName()).setCacheDuration(Duration.NONE));
         } catch (Exception e) {
             // cannot be notifies beacause the use of scheduleRequestHandlerAfterCurrent
             LOG.error("Error downloading file", e);
index da27e2b..6ede95f 100644 (file)
@@ -27,6 +27,7 @@ import org.apache.wicket.ajax.AjaxRequestTarget;
 import org.apache.wicket.behavior.AbstractAjaxBehavior;
 import org.apache.wicket.request.handler.resource.ResourceStreamRequestHandler;
 import org.apache.wicket.request.resource.ContentDisposition;
+import org.apache.wicket.util.time.Duration;
 
 public abstract class AjaxDownload extends AbstractAjaxBehavior {
 
@@ -79,6 +80,7 @@ public abstract class AjaxDownload extends AbstractAjaxBehavior {
 
         handler.setFileName(fileName);
         handler.setContentDisposition(ContentDisposition.ATTACHMENT);
+        handler.setCacheDuration(Duration.NONE);
         getComponent().getRequestCycle().scheduleRequestHandlerAfterCurrent(handler);
     }