bertramdev / grails-asset-pipeline

Grails Asset Pipeline

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Assets are not cached

verglor opened this issue · comments

Since version 2.9.0 assets are served with HTTP header Cache-Control: no-cache in production.

Are you using non cache digested versions of the assets? Because that was a
correction made requiring a server etag check

On Aug 4, 2016 7:16 PM, "jako512" notifications@github.com wrote:

Since version 2.9.0 assets are served with HTTP header Cache-Control:
no-cache in production.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#368, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AABaEl9vSazJXBnRjGLpl3lJx3OqQn2Sks5qcnK8gaJpZM4JdNo-
.

I'm using assets with cache digest.

can you send me a screen shot and sample header please?

Version 2.8.0 + PR#365:

λ curl -I https://www.zzz.sk/assets/logo-25ee681213a59b0c332c4fc085efd3ea.png
HTTP/1.1 200 OK
Server: nginx
Date: Fri, 05 Aug 2016 12:42:55 GMT
Content-Type: image/png; charset=UTF-8
Content-Length: 1908
Connection: keep-alive
Last-Modified: Thu, 04 Aug 2016 23:37:08 GMT
ETag: "logo-25ee681213a59b0c332c4fc085efd3ea.png"
Vary: Accept-Encoding
Cache-Control: public, max-age=31536000
Strict-Transport-Security: max-age=31536000
X-XSS-Protection: 1; mode=block

Version 2.10.1:

λ curl -I https://stag.zzz.sk/assets/logo-25ee681213a59b0c332c4fc085efd3ea.png
HTTP/1.1 200 OK
Server: nginx
Date: Fri, 05 Aug 2016 12:48:15 GMT
Content-Type: image/png; charset=UTF-8
Content-Length: 1908
Connection: keep-alive
Last-Modified: Pi, 05 aug 2016 12:44:48 GMT
ETag: "logo-25ee681213a59b0c332c4fc085efd3ea.png"
Vary: Accept-Encoding
Cache-Control: no-cache
Strict-Transport-Security: max-age=31536000
X-XSS-Protection: 1; mode=block

Thank you! are you routing this through nginx direct to tomcat or using storagePath copy?

On Aug 5, 2016, at 8:52 AM, jako512 notifications@github.com wrote:

Version 2.8.0 + PR#365:

λ curl -I https://www.zzz.sk/assets/logo-25ee681213a59b0c332c4fc085efd3ea.png
HTTP/1.1 200 OK
Server: nginx
Date: Fri, 05 Aug 2016 12:42:55 GMT
Content-Type: image/png; charset=UTF-8
Content-Length: 1908
Connection: keep-alive
Last-Modified: Thu, 04 Aug 2016 23:37:08 GMT
ETag: "logo-25ee681213a59b0c332c4fc085efd3ea.png"
Vary: Accept-Encoding
Cache-Control: public, max-age=31536000
Strict-Transport-Security: max-age=31536000
X-XSS-Protection: 1; mode=block
Version 2.10.1:

λ curl -I https://stag.zzz.sk/assets/logo-25ee681213a59b0c332c4fc085efd3ea.png
HTTP/1.1 200 OK
Server: nginx
Date: Fri, 05 Aug 2016 12:48:15 GMT
Content-Type: image/png; charset=UTF-8
Content-Length: 1908
Connection: keep-alive
Last-Modified: Pi, 05 aug 2016 12:44:48 GMT
ETag: "logo-25ee681213a59b0c332c4fc085efd3ea.png"
Vary: Accept-Encoding
Cache-Control: no-cache
Strict-Transport-Security: max-age=31536000
X-XSS-Protection: 1; mode=block

You are receiving this because you commented.
Reply to this email directly, view it on GitHub #368 (comment), or mute the thread https://github.com/notifications/unsubscribe-auth/AABaEjg8g3phUUbaL4o3u7eJUr2wWPZtks5qczINgaJpZM4JdNo-.

Direct nginx -> jetty

Issue still confirmed on 2.11.0

Id try a newer version and also @majkelo send an example. If the asset is not using a cache digest name it does a no-cache which doesn't mean its not being cached it means its asking the server to validate its ETag header properly

I've included plugin inline and manually updated asset-pipeline-core to 2.11.2 (just like in #378 but without any changes in AssetPipelineFilter.groovy ) and it seems it's working!

btw I'm not sure about https://github.com/bertramdev/asset-pipeline/blob/d51380f5c3847e695cd81cbc9991aecba7a1ea9e/asset-pipeline-core/src/main/groovy/asset/pipeline/AssetPipelineResponseBuilder.groovy#L63
for example for file /assets/grid.css what property should I add to Config.groovy?

I already have:

    grails.assets.skipNonDigests = true
    grails.assets.enableDigests = true
    grails.assets.bundle = false

I just noticed this on Grails 3.2.11 with asset-pipeline-grails:2.14.1 when I ran a standalone jar with prod environment.

My varnish server refused to cache images because of this.
Changing back to the older 2.8.2 version fixes this.

This happen with images and other kind blobs like fonts. Javascript and CSS works correctly.