Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Content Encoding Warning #999

Open
vpfaulkner opened this issue Dec 8, 2022 · 7 comments
Open

[Bug] Content Encoding Warning #999

vpfaulkner opened this issue Dec 8, 2022 · 7 comments

Comments

@vpfaulkner
Copy link

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
Copy link
Collaborator

bollain commented Dec 13, 2022

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
Copy link
Author

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

@bollain
Copy link
Collaborator

bollain commented Feb 17, 2023

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
Copy link

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

@bollain
Copy link
Collaborator

bollain commented Mar 2, 2024

Hi @gintechsystems,

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

@4kochi
Copy link

4kochi commented Jun 19, 2024

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
Copy link
Collaborator

bollain commented Jun 20, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants