Why does WebViewer give a warning about Content-Encoding when loading from my server?

4195 views
Skip to first unread message

David Tippett

unread,
Dec 12, 2017, 5:33:00 PM12/12/17
to pdfnet-w...@googlegroups.com
Q: I encountered the warning "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." when running WebViewer on my server. What does this mean and how do I fix this?

A: WebViewer contains certain large files that are already compressed using brotli (abbreviated br) or gzip encoding. As the warning suggests for ideal performance your server should be adjusted to serve these files with the HTTP Content-Encoding header. (see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding for more details on Content-Encoding) The main reason for this is that with this header the browser can quickly decompress these files using native code. Note that WebViewer can still function by decompressing these files in JavaScript, but this may have an impact on loading speed.

General Steps
1. Note that in order to serve files with Content-Encoding: br your site must use HTTPS rather than HTTP. This is due to behaviour in certain browsers (in particular Chrome) that leads them to reject brotli encoding served over HTTP.
2. The goal is to serve files within WebViewer containing ".gz." in their file name with "Content-Encoding: gzip" and files containing ".br." in their file name with "Content-Encoding: br".

Specific Instructions:
For Apache servers: WebViewer includes an .htaccess file (under WebViewer/lib/core) to implement this logic, so in most cases the only necessary step is to enable the mod_headers module. Note that this will only work if .htaccess is enabled for your particular server.

For S3: Using a tool such as Cloudberry (S3 browser should also have similar functionality) you can directly set the Content-Encoding of a particular file by clicking other mouse button on the file to pop up the context menu -> Set HTTP headers -> Enter Content-Encoding and either gzip or br depending on the file. S3 also provides scripting APIs that can accomplish the same result when uploading if this needs to be done frequently.

jan...@wellsuitedsolutions.com

unread,
Jun 4, 2018, 12:54:05 PM6/4/18
to PDFTron WebViewer
What are the instructions for how to configure this on IIS servers?
Thank you

On Tuesday, December 12, 2017 at 5:33:00 PM UTC-5, David Tippett wrote:
Q: I encountered the warning "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." when running WebViewer on my server. What does this mean and how do I fix this?

A: WebViewer contains certain large files that are already compressed using brotli (abbreviated br) or gzip encoding. As the warning suggests for ideal performance your server should be adjusted to serve these files with the HTTP Content-Encoding header. (see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding for more details on Content-Encoding) The main reason for this is that with this header the browser can quickly decompress these files using native code. Note that WebViewer can still function by decompressing these files in JavaScript, but this may have an impact on loading speed.

General Steps
1. Note that in order to serve files with Content-Encoding: br your site must use HTTPS rather than HTTP. This is due to behaviour in certain browsers (in particular Chrome) that leads them to reject brotli encoding served over HTTP.
2. The goal is to serve files within WebViewer containing ".gz." in their file name with "Content-Encoding: gzip" and files containing ".br." in their file name with "Content-Encoding: br".

Specific Instructions:
For Apache servers: WebViewer includes an .htaccess file (under WebViewer/lib/html5) to implement this logic, so in most cases the only necessary step is to enable the mod_headers module. Note that this will only work if .htaccess is enabled for your particular server.

David Tippett

unread,
Jun 4, 2018, 4:44:38 PM6/4/18
to pdfnet-w...@googlegroups.com
Good question. Here are some steps to get you set up:

1. If the url rewrite module is not available/installed you can install it from https://www.iis.net/downloads/microsoft/url-rewrite.

2. Put the attached web.config file in the WebViewer/lib/core folder.

I tested on IIS 10, though this should work on IIS 7 and above. (web.config is only supported on IIS 7+)

David Tippett
Senior Software Developer
PDFTron Systems Inc.
web.config

Janina Tassone

unread,
Jun 6, 2018, 1:41:28 PM6/6/18
to PDFTron WebViewer on behalf of David Tippett
If I place the web.config where you describe the rewrite rules do not get loaded, and the same message displays re "Your server has not been configured etc"

If I add the rewrite rules to the application root web.config, there is an Internal Server Error with the following message in the console:
TypeError: this.contentWindow.$ is not a function[Learn More]  in WebViewer.js

I am running ASP.NET MVC app with routing rules, I am thinking this may have something to do with why the web.config cannot be found in the html5 directory. However can the rules be rewritten such that they can be placed in the root web.config without interfering with WebViewer.js?

Thank you.

On Mon, Jun 4, 2018 at 4:44 PM, David Tippett via PDFTron WebViewer <pdfnet-webviewer+APn2wQdMpuPo7bE...@googlegroups.com> wrote:
Good question. Here are some steps to get you set up:

1. If the url rewrite module is not available/installed you can install it from https://www.iis.net/downloads/microsoft/url-rewrite.

2. Put the attached web.config file in the WebVIewer/lib/html5 folder.

I tested on IIS 10, though this should work on IIS 7 and above. (web.config is only supported on IIS 7+)

David Tippett
Senior Software Developer
PDFTron Systems Inc.

On Monday, June 4, 2018 at 9:54:05 AM UTC-7, (unknown) wrote:
What are the instructions for how to configure this on IIS servers?
Thank you

--
You received this message because you are subscribed to a topic in the Google Groups "PDFTron WebViewer" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pdfnet-webviewer/SeVvEpPAELg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pdfnet-webviewer+unsubscribe@googlegroups.com.
To post to this group, send email to pdfnet-webviewer@googlegroups.com.
Visit this group at https://groups.google.com/group/pdfnet-webviewer.
For more options, visit https://groups.google.com/d/optout.



--
Janina Tassone
Well Suited Solutions LLC
617-480-2911 (M) 
jan...@wellsuitedsolutions.com

Deon Kuhn

unread,
Feb 15, 2019, 12:31:22 PM2/15/19
to PDFTron WebViewer
The .htaccess file is no longer in the WebViewer/lib/html5 in the latest download of WebViewer, could you please post it here?


On Wednesday, June 6, 2018 at 7:41:28 PM UTC+2, Janina Tassone wrote:
If I place the web.config where you describe the rewrite rules do not get loaded, and the same message displays re "Your server has not been configured etc"

If I add the rewrite rules to the application root web.config, there is an Internal Server Error with the following message in the console:
TypeError: this.contentWindow.$ is not a function[Learn More]  in WebViewer.js

I am running ASP.NET MVC app with routing rules, I am thinking this may have something to do with why the web.config cannot be found in the html5 directory. However can the rules be rewritten such that they can be placed in the root web.config without interfering with WebViewer.js?

Thank you.
On Mon, Jun 4, 2018 at 4:44 PM, David Tippett via PDFTron WebViewer <pdfnet-webviewer+APn2wQdMpuPo7bEZ1iEgFMter3AEQTw-IvfVxlrweW-kgPA@googlegroups.com> wrote:
Good question. Here are some steps to get you set up:

1. If the url rewrite module is not available/installed you can install it from https://www.iis.net/downloads/microsoft/url-rewrite.

2. Put the attached web.config file in the WebVIewer/lib/html5 folder.

I tested on IIS 10, though this should work on IIS 7 and above. (web.config is only supported on IIS 7+)

David Tippett
Senior Software Developer
PDFTron Systems Inc.

On Monday, June 4, 2018 at 9:54:05 AM UTC-7, (unknown) wrote:
What are the instructions for how to configure this on IIS servers?
Thank you

On Tuesday, December 12, 2017 at 5:33:00 PM UTC-5, David Tippett wrote:
Q: I encountered the warning "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." when running WebViewer on my server. What does this mean and how do I fix this?

A: WebViewer contains certain large files that are already compressed using brotli (abbreviated br) or gzip encoding. As the warning suggests for ideal performance your server should be adjusted to serve these files with the HTTP Content-Encoding header. (see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding for more details on Content-Encoding) The main reason for this is that with this header the browser can quickly decompress these files using native code. Note that WebViewer can still function by decompressing these files in JavaScript, but this may have an impact on loading speed.

General Steps
1. Note that in order to serve files with Content-Encoding: br your site must use HTTPS rather than HTTP. This is due to behaviour in certain browsers (in particular Chrome) that leads them to reject brotli encoding served over HTTP.
2. The goal is to serve files within WebViewer containing ".gz." in their file name with "Content-Encoding: gzip" and files containing ".br." in their file name with "Content-Encoding: br".

Specific Instructions:
For Apache servers: WebViewer includes an .htaccess file (under WebViewer/lib/html5) to implement this logic, so in most cases the only necessary step is to enable the mod_headers module. Note that this will only work if .htaccess is enabled for your particular server.

For S3: Using a tool such as Cloudberry (S3 browser should also have similar functionality) you can directly set the Content-Encoding of a particular file by clicking other mouse button on the file to pop up the context menu -> Set HTTP headers -> Enter Content-Encoding and either gzip or br depending on the file. S3 also provides scripting APIs that can accomplish the same result when uploading if this needs to be done frequently.

--
You received this message because you are subscribed to a topic in the Google Groups "PDFTron WebViewer" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pdfnet-webviewer/SeVvEpPAELg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pdfnet-webview...@googlegroups.com.
To post to this group, send email to pdfnet-w...@googlegroups.com.

Zhijie Zhang

unread,
Feb 15, 2019, 6:45:55 PM2/15/19
to PDFTron WebViewer
Hi Deon,

Attached is the .htaccess file. This file will also be included in the next version of WebViewer download package.

Best Regards,
Zhijie Zhang
.htaccess

Gowtham Lcs

unread,
Mar 21, 2019, 12:50:32 PM3/21/19
to PDFTron WebViewer
Hi Team,

While adding Content-Encoding as response header, I am getting errors and warnings as attached. I am unable to preview the document thereafter. Please help me on this.

Regards,
Gowtham C


On Wednesday, December 13, 2017 at 4:03:00 AM UTC+5:30, David Tippett wrote:
Q: I encountered the warning "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." when running WebViewer on my server. What does this mean and how do I fix this?

A: WebViewer contains certain large files that are already compressed using brotli (abbreviated br) or gzip encoding. As the warning suggests for ideal performance your server should be adjusted to serve these files with the HTTP Content-Encoding header. (see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding for more details on Content-Encoding) The main reason for this is that with this header the browser can quickly decompress these files using native code. Note that WebViewer can still function by decompressing these files in JavaScript, but this may have an impact on loading speed.

General Steps
1. Note that in order to serve files with Content-Encoding: br your site must use HTTPS rather than HTTP. This is due to behaviour in certain browsers (in particular Chrome) that leads them to reject brotli encoding served over HTTP.
2. The goal is to serve files within WebViewer containing ".gz." in their file name with "Content-Encoding: gzip" and files containing ".br." in their file name with "Content-Encoding: br".

Specific Instructions:
For Apache servers: WebViewer includes an .htaccess file (under WebViewer/lib/html5) to implement this logic, so in most cases the only necessary step is to enable the mod_headers module. Note that this will only work if .htaccess is enabled for your particular server.
GZIP.JPG

Matt Parizeau

unread,
Mar 21, 2019, 8:50:13 PM3/21/19
to PDFTron WebViewer
Hi Gowtham,

Are you adding the Content-Encoding header to all responses? You'll only want to add the Content-Encoding header if the filename includes .gz or .br as shown in the example htaccess file.

Matt Parizeau
Software Developer
PDFTron Systems Inc.

Gowtham Lcs

unread,
Mar 22, 2019, 12:30:12 PM3/22/19
to PDFTron WebViewer
Hi Matt,

I am still unclear about the ".gz" and ".br" error. You mentioned that the Content-Encoding header must be used only if the filename includes ".br" or ".gz". So, the filename that we have with the matched extension is PDFNetCWasm.br.js . In this case, this file is loaded correctly, but still I get that error. How do I clear the warning? Where do I need to add the Content-Encoding header, because the above mentioned br file will be called by Pdftron resource itself. Is there any setting to do with the IIS? In one of the post, it was mentioned as below.


1. If the url rewrite module is not available/installed you can install it from https://www.iis.net/downloads/microsoft/url-rewrite.

2. Put the attached web.config file in the WebVIewer/lib/html5 folder.

Is there anything to be added in the url rewrite? I have attached the web.config, but I am getting the error as it is failed to load. Please help me on this.

Gowtham Lcs

unread,
Mar 27, 2019, 4:49:24 PM3/27/19
to PDFTron WebViewer
Hi Team,

Can you please help me on my previous post related to IIS setup?

Matt Parizeau

unread,
Mar 28, 2019, 7:56:26 PM3/28/19
to PDFTron WebViewer
Hi Gowtham,

There shouldn't be anything else you need to do to activate URL rewrite. Here are is a page that discusses installing it http://web-site-scripts.com/knowledge-base/article/AA-00470/0. Note that you may also need to restart your server https://stackoverflow.com/questions/18261507/change-to-web-config-on-server-is-not-going-into-effect.

We confirmed that enabling the module and using the web.config produces the desired effect on our end. What version of IIS are you running?

At the end of the day it isn't critical to have this setup as the files can still be decompressed in the browser.

Matt Parizeau
Software Developer
PDFTron Systems Inc.

Gowtham Lcs

unread,
Apr 2, 2019, 2:25:24 PM4/2/19
to PDFTron WebViewer
Hi Matt,

We are not rewrinting anything in the URL and hence we dont use URL rewrite here. So, can you please tell us how can we resolve this warning?

Gowtham Lcs

unread,
Apr 2, 2019, 2:25:24 PM4/2/19
to PDFTron WebViewer
Hi Matt,

We are not rewriting any url, so how can we get rid of those warnings?

Matt Parizeau

unread,
Apr 22, 2019, 2:22:19 PM4/22/19
to PDFTron WebViewer
Hi Gowtham,

If you aren't able to get the web.config to work on your server then as mentioned you can simply ignore the warning as the files will instead be decompressed in the browser.

Matt Parizeau
Software Developer
PDFTron Systems Inc.
Reply all
Reply to author
Forward
0 new messages