Search code examples
grailsetag

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


I add plugin

compile ":cache-headers:1.1.7"

and in config file next line:

cache.headers.enabled = false

now I'm sending this:

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

but how I understand in my request also should be: If-Modified-Since, If-None-Match and after refresh I should get 302 status but I always get status 200.


Solution

  • You want a 304 status - 302 is a redirect. But the cache-headers plugin isn't what you want, that's for controller responses. The asset-pipeline plugin and its addon plugins manage caching, minification, etc. for static resources.