From 9e37277c4a5d4c353f71ec5060951c554f20bab5 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Fri, 21 Sep 2012 22:13:53 +0000 Subject: [PATCH] prevent caching when browsing a directory git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1388705 13f79535-47bb-0310-9956-ffa450edef68 --- .../webdav/ArchivaDavResourceFactory.java | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java index ba8f4ce22..c8fe1b87b 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java @@ -112,7 +112,7 @@ import java.util.Set; /** * */ -@Service ( "davResourceFactory#archiva" ) +@Service ("davResourceFactory#archiva") public class ArchivaDavResourceFactory implements DavResourceFactory, Auditable { @@ -145,7 +145,7 @@ public class ArchivaDavResourceFactory * */ @Inject - @Named ( value = "repositoryProxyConnectors#default" ) + @Named (value = "repositoryProxyConnectors#default") private RepositoryProxyConnectors connectors; /** @@ -175,7 +175,7 @@ public class ArchivaDavResourceFactory * */ @Inject - @Named ( value = "httpAuthenticator#basic" ) + @Named (value = "httpAuthenticator#basic") private HttpAuthenticator httpAuth; @Inject @@ -208,7 +208,7 @@ public class ArchivaDavResourceFactory * */ @Inject - @Named ( value = "archivaTaskScheduler#repository" ) + @Named (value = "archivaTaskScheduler#repository") private RepositoryArchivaTaskScheduler scheduler; private ApplicationContext applicationContext; @@ -852,10 +852,19 @@ public class ArchivaDavResourceFactory response.setHeader( "Pragma", "no-cache" ); response.setHeader( "Cache-Control", "no-cache" ); } - - // We need to specify this so connecting wagons can work correctly - response.setDateHeader( "last-modified", resource.getModificationTime() ); - + // if the resource is a directory don't cache it as new groupId deployed will be available + // without need of refreshing browser + if ( ( (ArchivaDavResource) resource ).getLocalResource().isDirectory() ) + { + response.setHeader( "Pragma", "no-cache" ); + response.setHeader( "Cache-Control", "no-cache" ); + response.setDateHeader( "last-modified", new Date().getTime() ); + } + else + { + // We need to specify this so connecting wagons can work correctly + response.setDateHeader( "last-modified", resource.getModificationTime() ); + } // TODO: [MRM-524] determine http caching options for other types of files (artifacts, sha1, md5, snapshots) } -- 2.39.5