如何在 grails 中发送 etag 302 状态而不是每次都加载 js 和其他资源?

How in grails send with etag 302 status and not load js and other resource every time?

我添加插件

compile ":cache-headers:1.1.7"

在配置文件的下一行:

cache.headers.enabled = false

现在我要发送这个:

Request URL:http://localhost:8080/SomeProject/js/pages/somePage.js?_=1444319608606
Request Method:GET
Status Code:200 OK
Response Headers
view source
Accept-Ranges:bytes
Content-Length:3757
Content-Type:application/javascript
Date:Thu, 08 Oct 2015 15:56:09 GMT
ETag:W/"3757-1432890402118"
Last-Modified:Fri, 29 May 2015 09:06:42 GMT
Server:Apache-Coyote/1.1
Request Headers
view source
Accept:text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01
Accept-Encoding:gzip, deflate, sdch
Accept-Language:ru,en-US;q=0.8,en;q=0.6,en-GB;q=0.4
Connection:keep-alive
Cookie:JSESSIONID=80DE99527007982AF9016B65B20E05D2; _ga=GA1.1.494624836.1438596076
Host:localhost:8080
Referer:http://localhost:8080/SomeProject/
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36
X-Requested-With:XMLHttpRequest
Query String Parameters
view source
view URL encoded
_:1444319608606

但我在我的要求中的理解也应该是: If-Modified-Since, 如果-None-匹配 刷新后我应该获得 302 状态,但我总是获得状态 200。

您需要一个 304 status - 302 is a redirect. But the cache-headers plugin isn't what you want, that's for controller responses. The asset-pipeline 插件及其插件管理静态资源的缓存、缩小等。