OptimizeForBandwidth

Rewriting Level

The OptimizeForBandwidth setting provides a stronger guarantee of safety then CoreFilters and is suitable as a default setting for use with sites that are not aware of PageSpeed.

pagespeed RewriteLevel OptimizeForBandwidth

This option is suitable for use in a root configuration at a hosting service, CDN, or multi-site setup. In this mode, PageSpeed does not alter HTML at all. It compresses and transcodes images in place, and minifies JavaScript and CSS. By avoiding changes to URL syntax and to HTML, the potential problem of user-written JavaScript encountering unexpected DOM elements is elimimated. There is still latency benefit due to the reduced size of resources, as well as substantial bandwidth reduction.

Bandwidth Savings

The bandwidth savings resulting from this option are, of course, dependent on the source site. Our tests with the default settings for OptimizeForBandwidth indicate an average bandwidth reduction of roughly 37% over the content of 1000 large web sites with a client that is capable of displaying webp images, and 25% improvement with older clients.

Adding Additional Options

Additional latency optimizations that modify HTML can be layered on top of OptimizeForBandwidth by enabling additional filters, and altering the Preserve URL settings for CSS, images, or JavaScript. For example, to set up a shared hosting server with OptimizeForBandwidth in the root, but where individual sites have added inline_javascript, lazyload_images and prioritize_critical_css, or simply turned on CoreFilters, the following configuration fragment may be used:

# In root configuration: pagespeed RewriteLevel OptimizeForBandwidth # Site or host specific configuration, prioritize_above_the_fold pagespeed EnableFilters inline_javascript,prioritize_critical_css,inline_preview_images # Site or host specific configuration, preserve_css_urls_off pagespeed CssPreserveURLs off # Site or host specific configuration, core filters pagespeed RewriteLevel CoreFilters

As of PageSpeed 1.9.32.1 and later, In Place Resource Optimization is enabled by default. In earlier versions, turning on OptimizeForBandwidth automatically enables In Place Resource Optimization to optimize the resources without needing to change their URLs. In these earlier versions, when a VirtualHost overrides the RewriteLevel to CoreFilers, that turns off In Place Resource Optimization, but it can be re-enabled explicitly:

pagespeed InPlaceResourceOptimization on

Note: OptimizeForBandwidth is a new feature as of PageSpeed 1.8.31.2