In-Place Resource Optimization (IPRO)
Note: Enabled by default as of PageSpeed 184.108.40.206
pagespeed InPlaceResourceOptimization on
Doing browser-specific in-place optimization
PageSpeed has a number of optimizations that are browser-specific. For example, WebP conversion is performed only for browsers that can display WebP images. Ordinarily PageSpeed accomplishes this by serving different rewritten URLs to different browsers depending upon their capabilities. For resources that are rewritten in place, this isn't possible; instead, appropriate headers (such as Vary: Accept and Vary: User-Agent) are added to rewritten resources as necessary. Enable these browser-specific optimizations as follows:
pagespeed EnableFilters in_place_optimize_for_browser
By default, when
in_place_optimize_for_browser is enabled, appropriate
Vary: headers are added to resources that are subject to browser-specific optimization. CSS files are served with a
Vary: User-Agent header. Photographic images that are candidates for WebP conversion are served with
Vary: Accept to browsers that include
Accept: image/webp in their headers. Note that while the most recent versions of browsers that display WebP images include this header in image requests, older WebP-capable browsers do not — as a result, a slightly smaller subset of browsers will receive WebP images than would be the case if the URLs were rewritten.
Internet Explorer has difficulty caching resources with
Vary: headers (they are either not cached or require revalidation on every resource access). As a result, browser-specific in-place resources are instead marked
Cache-Control: private when served to all versions of Internet Explorer.
Setting the inplace resource rewrite deadline
When InPlaceResourceOptimization is enabled, PageSpeed uses a default deadline of 10ms the when optimizing the resource. If the optimization cannot be completed in 10ms, then the original resource is served to the client, while the optimization continues in the background. Once cached, the optimized resource will be served for further requests. Note that a value less than zero will cause PageSpeed to wait indefinitely.
Also note that in-place-optimized resources generally take at least two refreshes to optimize regardless of the deadline, due to the current architecture of the server modules.
pagespeed InPlaceRewriteDeadlineMs deadline_value_in_milliseconds
This directive can be used at all configuration levels.
Resources optimized by in-place resource optimization are optimized differently from resources found in HTML, JS, and CSS. First, rewritten pagespeed URLs contain a content hash that enables the optimized data to be cached for a year by browser and proxy caches; in-place resources are not cache extended. Second, in-place resources can't be optimized specially for the context in which they occur on the page: images can't be resized to the size they appear on the page, and multiple resources on a page can’t be combined together. Finally, in-place resources that are eligible for browser-specific optimizations (such as conversion to the WebP image format) will be served with the
Vary: User-Agent caching header, reducing caching at intermediate proxies.
In-place resource optimization will add a new cache entry for every unique URL requested. It will also copy each request into memory once. If you have a large site with many uncacheable resources, this could quickly fill up your cache or cause a lot of expensive string copies.
In-place optimization will also add a small delay to every server response, this should not be large and we have not been able to measure any noticeable slow-down, but if most of your resources are uncacheable, you may wish to avoid this cost.