Closed daniellansun closed 9 years ago
This has to do with asset pipeline I imagine. @davydotcom you seen this behaviour anywhere?
I have not, what version of asset pipeline is being used
3.0.9 uses 3.0.8 of the asset pipeline plugin
Thanks for your quick reply!
BTW Grails 3.0.8 can generate ETag for artefacts under "grails/assets" directory, but no ETag generated for artefacts under "src/main/webapp" directory.
Ah I see, that should be been put in the description then.
Hi Graeme,
When I launch Grails app through "grails prod run-app" command, no ETags are generated for artefacts under "grails/assets" directory either.
@danielsun1106 that is not the proper way to simulate a production run of grails. You must use the assembled fat jar container or war file to run in production mode properly. the asset-pipeline will still detect that the app is running in an unpackaged mode like this as run-app
is solely used for development purposes.
Also this is correct src/main/webapp
is considered a non asset-pipeline processed resource folder. I do not believe even grails 2.5.1 processes the web app folder either
Hi David, In the grails 2.5.1 project, the only directory to place js library(such as jquery-ui which contains js, css, images under single directory and not be classified as javascripts/stylesheets/images) is "web-app". It is true that artefacts can be cached properly.
Could you tell me how to place js library such as jquery-ui under "grails/assets" in the Grails3? Thanks in advance.
This is not true. Remember all subfolders immediately under the assets
folder are purely for organizational purpose. They do not specifically restrict the type of file to be placed in them. You can even create your own subdirectory within assets
named however you see fit. For example, I often make a grails-app/assets/libs
folder and store things like this in there.
@davydotcom Thanks for your sharing experience. When I make a grails-app/assets/libs folder and store things as you often do, how can I access these artefacts in the gsp page?
When I put images in the "assets/images", the images should be accessed by the following code:
<img src="${asset.assetPath(src: 'test.jpg')}" />
or
<asset:image src="test.jpg"/>
When I put images in the "assets/libs", how can I access these js, css and images files? Thanks in advance.
Just like you would an image. Lets say you put test.jpg
in grails-app/assets/libs
instead of images
. The way you would reference that file is identical `
It works! I'll migrate all my js lib to assets/libs. Thank you very much!
Id say we can close this ticket
Thanks @davydotcom
Even when running under production mode, Grails 3.0.9 does not generate ETag for artefacts(e.g. js, css, image files) and make browsers cache them . BTW, Grails 2.5.1 can cache artefacts properly.