google / ngx_brotli

NGINX module for Brotli compression
BSD 2-Clause "Simplified" License
2.1k stars 216 forks source link

`brotli_static` works on localhost but not on real server #128

Closed anders-kiaer closed 2 years ago

anders-kiaer commented 2 years ago

With the following example nginx.conf snippet:

    server {
        listen 8080 default_server;

        location / {
            brotli off;
            brotli_static on;

            root /usr/share/nginx/build;
            try_files $uri =404;
        }

we correctly get the [...].js.br versions when requesting [...].js on localhost, but when deployed to cloud service web app the uncompressed file [...].js is returned despite both scenarios have Accept encoding: gzip, deflate, br sent by the Chrome browser.

If adding

    brotli on;
    brotli_comp_level 4;

as well, we still correctly get the statically compressed files on localhost, and in deployed app we get dynamically compressed versions (i.e. they are compressed, but not the expected statically compressed files).

I.e. the problem appears to be limited to statically compressed file not on localhost.

Any input on how to debug or what this could be due to? E.g. is localhost and external server treated differently and requires different nginx setups, or could it be related to http (localhost) and https when accessing it on the cloud app? Or related to cloud vendor probably having their own proxy in front of ours? For gzip there is gzip_proxied, but this appears not to be necessary to configure with ngx_brotli according to #53. :thinking:

anders-kiaer commented 2 years ago

After some detailed debugging, turned out this is not related to ngx_brotli at all - and was due to same as described here https://stackoverflow.com/q/66385965 and the cloud vendor persisting volumes across deploys even when they say volumes will not persist.

Sorry for the noise. :slightly_smiling_face: