Example usage for org.springframework.http CacheControl noStore

List of usage examples for org.springframework.http CacheControl noStore

Introduction

In this page you can find the example usage for org.springframework.http CacheControl noStore.

Prototype

boolean noStore

To view the source code for org.springframework.http CacheControl noStore.

Click Source Link

Usage

From source file:org.ownchan.server.app.config.WebMvcConfig.java

@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
    String implementationVersion = ScanBaseMarker.class.getPackage().getImplementationVersion();

    String pathVersion;/*ww  w .  java2s  .  c  o  m*/
    CacheControl cacheControl;
    if (StringUtils.isNotBlank(implementationVersion)) {
        /*
         * As we use versioning for the GUI URL paths, we can cache "forever".
         * Browsers will re-validate when the resource's URL changes with every new version of the application.
         */
        cacheControl = CacheControl.maxAge(365, TimeUnit.DAYS);
        pathVersion = implementationVersion;
    } else {
        /*
         * If the application is started directly in the DEV IDE,
         * we don't cache and allow all versions in the path.
         */
        cacheControl = CacheControl.noStore();
        pathVersion = "{version:[a-zA-Z0-9\\.\\-]+}";
    }

    addStaticResourceHandlers(registry, cacheControl, "/static/" + pathVersion + "/**");
}

From source file:org.ownchan.server.ui.core.config.WebMvcConfig.java

@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
    String implementationVersion = ScanBaseMarker.class.getPackage().getImplementationVersion();

    String pathVersion;/* w  ww.  j  av  a  2s .  c o m*/
    CacheControl cacheControl;
    if (StringUtils.isNotBlank(implementationVersion)) {
        /*
         * As we use versioning for the GUI URL paths, we can cache "forever".
         * Browsers will re-validate when the resource's URL changes with every new version of the application.
         */
        cacheControl = CacheControl.maxAge(365, TimeUnit.DAYS);
        pathVersion = implementationVersion;
    } else {
        /*
         * If the application is started directly in the DEV IDE,
         * we don't cache and allow all versions in the path.
         */
        cacheControl = CacheControl.noStore();
        pathVersion = "{version:[a-zA-Z0-9\\.\\-]+}";
    }

    String webBasePath = "/ocn-ui-core/" + pathVersion;
    String localBasePath = "classpath:/ownchan-server-ui-core";

    registry.addResourceHandler(webBasePath + "/widgets/**")
            .addResourceLocations(localBasePath + "/jqx/jqwidgets/").setCacheControl(cacheControl);
    registry.addResourceHandler(webBasePath + "/common/**").addResourceLocations(localBasePath + "/common/")
            .setCacheControl(cacheControl);
}