remove response caching
Turn out, that caching on the client side does not play well when new data is loaded into the system.
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
package org.lucares.pdbui;
|
||||
|
||||
import java.nio.file.Paths;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.CacheControl;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@@ -13,13 +11,9 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
public class WebConfiguration implements WebMvcConfigurer, HardcodedValues, PropertyKeys {
|
||||
|
||||
private final String outputDir;
|
||||
private final int cacheDurationInSeconds;
|
||||
|
||||
public WebConfiguration(@Value("${" + PATH_GENERATED_IMAGES + "}") final String outputDir,
|
||||
@Value("${" + CACHE_IMAGES_DURATION_SECONDS + ":" + CACHE_IMAGES_DURATION_SECONDS_DEFAULT
|
||||
+ "}") final int cacheDurationInSeconds) {
|
||||
public WebConfiguration(@Value("${" + PATH_GENERATED_IMAGES + "}") final String outputDir) {
|
||||
this.outputDir = outputDir;
|
||||
this.cacheDurationInSeconds = cacheDurationInSeconds;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -28,7 +22,6 @@ public class WebConfiguration implements WebMvcConfigurer, HardcodedValues, Prop
|
||||
final String pathPattern = "/" + WEB_IMAGE_OUTPUT_PATH + "/**";
|
||||
final String resourceLocation = "file:" + Paths.get(outputDir).toAbsolutePath() + "/";
|
||||
|
||||
final CacheControl cacheControl = CacheControl.maxAge(cacheDurationInSeconds, TimeUnit.SECONDS);
|
||||
registry.addResourceHandler(pathPattern).addResourceLocations(resourceLocation).setCacheControl(cacheControl);
|
||||
registry.addResourceHandler(pathPattern).addResourceLocations(resourceLocation);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user