Not sure if it's a bug or a misconfiguration of the module.

I have enabled Compression in Configuration Tab:
Gzip CSS assets
Gzip JavaScript assets

I have also enabled minifcation

CSS minification
with YUI compressor

JavaScript Minification
JSMin ~2ms

When checking Network tools in Chrome, I could see that both size uncompressed and compressed are almost the same.
And the path to CSS or JS delivered is without the "optimized" folder and without .gz extension

In Drupal 7 we had to add a new location block in NGNIX configuration.

Not sure if it is still relavant in D8:

This what I'm using:

    ### advagg_css and advagg_js support
    ##
    location  ~ ^/sites/default/files/(?:css|js)/optimized {
       #gzip_static on; # I supposed it's not necessary if drupal/advagg are compressing it.
       access_log off;
       expires max;
       add_header ETag "";
       add_header Cache-Control "max-age=31449600, no-transform, public";
       try_files $uri @rewrite;
    }

Comments

heyyo created an issue. See original summary.

heyyo’s picture

I was misunderstanding the directive gzip_static on, it has to be here.
I thought it was telling to NGINX to compress on the fly the CSS/JS but in fact it's telling to NGINX that CSS/JS are already compressed.

So I changed it like this (without optimized)

  location  ~ ^/sites/default/files/(?:css|js) {
       gzip_static on;
       access_log off;
       expires max;
    }

I don't undesrtand why it's not added by default on the NGNIX Drupal recipe:
https://www.nginx.com/resources/wiki/start/topics/recipes/drupal/

But still, I don't uderstand the purpose of the optimized directory if it's not served ?

heyyo’s picture

Hum if I disable the aggregation of CSS and JS in Core, Drupal is now serving optimized version of CSS and JS, but tones of them !
It seems the bundler has still issues.

heyyo’s picture

Version: 8.x-3.0-rc1 » 8.x-3.0-rc2
nickdickinsonwilde’s picture

Title: Drupal doesn't serve optimized or gzip files » Doesn't serve or gzip/br optimized files under nginx
Status: Active » Needs work

Okay, you've hit 2 issues ;)
Issue 1: not serving gzip compressed assets, I'll see what I can do to make it less apache specific (at minimum include instructions to create files like you've included in this issue - I'll be looking at them for reference, thanks).

Issue 2: not serving from the optimized directory:
This is basically a documentation flaw; it is working as intended.
- As you saw, if you disabled core aggregation, the files from the optimized directory were served.
- If core aggregation is enabled: those optimized files are created and then used as needed to create the aggregates; instead of optimizing each file each time to create an aggregate, it do sit once.
There are a couple reasons, but primary is basically shown in this medium post I saw this morning:
https://medium.com/myplanet-musings/experimenting-with-drupal-and-http-2...
TL-DR: with HTTP2 better performance can be achieved with many small files rather than aggregates.
Improving the documentation is high on priority list and will be happening before full release.

Thanks for the report and details :)

  • NickWilde committed b9ca255 on 8.x-3.x
    Issue #2890634 by heyyo, NickWilde: Doesn't serve or gzip/br optimized...
nickdickinsonwilde’s picture

Version: 8.x-3.0-rc2 » 8.x-3.x-dev
Status: Needs work » Fixed

Finally got around to improving this. There is now a note on the settings form if using Apache, saying automatically handled or if Nginx linking to the manual which now has instructions on how to serve the compressed assets.
Thanks for the examples and information :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.