Commit b6ce7d05 authored by dpapad's avatar dpapad Committed by Commit Bot

Update compress="gzip" related documentation to reflect latest behavior.

WebUI Gzip/compression related documentation is quite obsolete and
does not reflect the following (not so recent anymore) changes:

 - compress="gzip" is the default behavior for HTML, JS, CSS and
   SVG files.
 - The UseGzip() C++ method no longer exists (as it is not necessary).

Bug: 1068407
Change-Id: I36be8895abd5b115c07a40d094e52d00efb9d764
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2290997Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Commit-Queue: dpapad <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#787664}
parent ee6af85d
......@@ -101,24 +101,18 @@ breakpoints on the un-minified version.
### Gzip compression of web resources
In certain cases, it might be preferable to leave web resources compressed on
disk and inflate them when needed (i.e. when a user wants to see a page).
In this case, you can run `gzip --rsyncable` on a resource before it's put into
a .pak file via GRIT with this syntax:
As of [r761031](https://chromium.googlesource.com/chromium/src/+/6b83ee683f6c545be29ee807c6d0b6ac1508a549)
all HTML, JS, CSS and SVG resources are compressed by default with gzip
Previously this was only happening if the `compress="gzip"` attribute was
specified as follows in the corresponding .grd file:
```xml
<include name="IDR_MY_PAGE" file="my/page.html" type="BINDATA" compress="gzip" />
```
Gzip is currently set up to apply to a whole WebUI's data source, though it's
possible to exclude specific paths for things like dynamically generated content
(i.e. many pages load translations dynamically from a path named "strings.js").
To mark a WebUI's resources compressed, you'll need to do something like:
This is no longer necessary, and should be omitted. Only specify the `compress`
attribute if the value is `false` or `brotli`.
```c++
WebUIDataSource* data_source = WebUIDataSource::Create(...);
data_source->SetDefaultResource(IDR_MY_PAGE);
data_source->UseGzip(); // Optional callback if exclusions are needed.
```
Compressed resources are uncompressed at a fairly low layer within
ResourceBundle, and WebUI authors typically do not need to do anything special
to serve those files to the UI.
......@@ -134,7 +134,9 @@ For more information on when to use `const char *` vs `const char[]`, see
#### What to do if the Check Fails?
- Add `compress="gzip"` to the `.grd` entry for the resource.
- Ensure that `compress="false"` is **not** being used in the `.grd` entry for
the resource, so that the default behavior of `compress="gzip"` is triggered
(for HTML, JS, CSS, and SVG files).
### Expectation Failures
......
......@@ -31,8 +31,11 @@ Feel free to email [binary-size@chromium.org](https://groups.google.com/a/chromi
[Grit] supports gzip and brotli compression for resources in the .grd files
used to build the `resources.pak` file.
* Ensure `compress="gzip"` or `compress="brotli"` is used for all
highly-compressible (e.g. text, WebUI) resources.
Note that `compress="gzip"` is already the default behavior for HTML, JS, CSS
and SVG files, when the `compress` attribute is not specified.
* Choose between gzip (default) or brotli (with `compress="brotli"`) as
follows
* gzip compression for highly-compressible data typically has minimal
impact on load times (but it is worth measuring this, see
[webui_load_timer.cc] for an example of measuring load times).
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment