ApryseSDK / webviewer-ui

WebViewer UI built in React
Other
416 stars 353 forks source link

[Bug] Content Encoding Warning #999

Open vpfaulkner opened 1 year ago

vpfaulkner commented 1 year ago

WebViewer version 8.10.0

The current behavior We get this console warning: webviewer-core.min.js:215 There may be some degradation of performance. Your server has not been configured to serve .gz. and .br. files with the expected Content-Encoding. See http://www.pdftron.com/kb_content_encoding for instructions on how to resolve this.

However, from what I can tell, the Content-Encoding header is being set to br

Pasted Graphic 1

Also, if I set a Chrome debugger to the line that throws that warning and look at the response, it includes the expected header:

image image

The expected behavior

No warning

Steps to reproduce

Not sure best way for you to reproduce this.

bollain commented 1 year ago

Hey @vpfaulkner,

Just wanted to let you know that we are looking at this internally. I'll provide more info when we determine why this doesn't appear to work as expected.

vpfaulkner commented 1 year ago

thanks @bollain. Let me know if there is anything else I can do.

bollain commented 1 year ago

hey @vpfaulkner, sorry for the delay on this one. We had a look internally and mapped the error you are seeing to the unminified source code. This error gets thrown when the compressed size of the brotli is less than what we expect to be the maximum compressed size. So potentially we think the file is getting compressed twice, one by us, and once by the server.

We have this guide on how to setup content-encoding in common server setups: https://github.com/PDFTron/Content-Encoding-Samples

Let me know if you get a chance to go over it.

gintechsystems commented 9 months ago

When will the nginx sample file get added to that repo?

bollain commented 9 months ago

Hi @gintechsystems,

Please reach out via our support system for further guidance on Nginx: https://apryse.com/form/request

4kochi commented 5 months ago

Dear @bollain,

we have warning message and want to fix in nginx. Is there an official documentation now for nginx, or do we also have to contact the support?

Greetings Andreas

bollain commented 5 months ago

Hi @4kochi,

To correctly set the response header for files that are compressed using Brotli in Nginx, you need to configure Nginx to recognize and serve Brotli compressed files. This involves setting the Content-Encoding header correctly and configuring Nginx to serve the pre-compressed Brotli files.

First ensure you have the Brotli configuration to your Nginx configuration file. For example:

load_module modules/ngx_http_brotli_filter_module.so;
load_module modules/ngx_http_brotli_static_module.so;

events {
    worker_connections 1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    # Brotli configuration
    brotli on;
    brotli_comp_level 6;
    brotli_static on;
    brotli_types application/wasm application/json text/plain text/css application/javascript application/x-javascript;

    server {
        listen 80;
        server_name localhost;

        location / {
            root /usr/share/nginx/html;
            brotli_static on;
            try_files $uri $uri/ =404;
        }

        location ~* \.(wasm|mem)$ {
            root /usr/share/nginx/html;

            # Serve Brotli files if they exist
            try_files $uri.br $uri =404;

            # Add Brotli header for .br files
            if ($http_accept_encoding ~* br) {
                add_header Content-Encoding br;
            }
        }
    }
}

More reference on the NGINX headers module here

This is of course a very basic example and intended only to get you started. Running this on my end on a simple app I no longer see the warnings for content encoding, but you will need to tweak this to your configuration and ensure everything works as expected. If you need further guidance please don't hesitate to post here or send a ticket via our support channel.