Spring-boot: Cache Period broken in 2.0.0.M7

Created on 7 Dec 2017  路  10Comments  路  Source: spring-projects/spring-boot

I'm an early adopter of Spring Boot 2. It works well so fare with M6, but today with M7 it's broken.

application.yml

spring:
  profiles:
    active: ${profile:dev}
  resources:
    cache-period: 600

Log:

***************************
APPLICATION FAILED TO START
***************************

Description:

Binding to target [Bindable@7e642b88 type = org.springframework.boot.autoconfigure.web.ResourceProperties, value = 'provided', annotations = array<Annotation>[[empty]]] failed:

    Property: spring.resources.cache-period
    Value: 600
    Origin: class path resource [application.yml]:16:19
    Reason: The elements [spring.resources.cache-period] were left unbound.

Action:

Update your application's configuration
invalid

Most helpful comment

Note: as of 2.0.0.M7, the actual configuration key is spring.resources.cache.period.

All 10 comments

@ghostd May be, but the 600 are not working as expected any more.

This looks like a duplicate of #11216. @MBurchard can you please try quoting 600 ("600") or using 2.0.0.BUILD-SNAPSHOT available from https://repo.spring.io/snapshot.

Note: as of 2.0.0.M7, the actual configuration key is spring.resources.cache.period.

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

can you please try quoting 600 ("600")

This does not help.

Note: as of 2.0.0.M7, the actual configuration key is spring.resources.cache.period.

This, together with quoting is the correct solution.

spring:
  profiles:
    active: ${profile:dev}
  resources:
    cache:
      period: "600"

Although I can't say if the caching really works correctly.

Running from Eclipse on a local Tomcat the headers of a CSS resource is are this:

grafik

Your browser tools or extensions are sending a 芦聽no-cache聽禄 header to the request. Please try the same with curl.

I have startet the application via bootRun and then used curl.

user@computer:~$ curl -v -O http://localhost:8080/css/styles.css
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /css/styles.css HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.47.0
> Accept: */*
>
< HTTP/1.1 200
< Last-Modified: Thu, 07 Dec 2017 14:45:30 GMT
< Accept-Ranges: bytes
< Content-Type: text/css
< Content-Length: 176584
< Vary: Accept-Encoding
< Date: Fri, 15 Dec 2017 07:21:10 GMT
<
{ [7999 bytes data]
100  172k  100  172k    0     0   9.8M      0 --:--:-- --:--:-- --:--:-- 10.5M
* Connection #0 to host localhost left intact

I can't see any cache headers.
styles.css is a static resource that comes from src\main\webapp

The src/main/webapp is not configured as a static location served by the Spring MVC resource handler. If you're packaging your app as a jar, you should not use that location at all. See the relevant section in the reference documentation.

There is no plan to package it as jar. It will be packaged as war.
Nevertheless thank you for that hint. I'll try to change that if necessary.
Currently I'm testing JHipster and that's why I do not focus any more on on Spring-Boot 2 Milestones... may be later

Was this page helpful?
0 / 5 - 0 ratings