+1 (617) 7782998 |

Manually Experimenting with PageSpeed

Per-request configuration

Query parameters, request headers, and response headers can be used to disable PageSpeed, specify the set of filters applied to an HTML page, and control some inlining limits.

Query parameters take the form of name=value and parameters are separated by an ampersand (&). For example:


Request and response headers take the form of name: value and each header is on its own line. For example:

GET /rewrite_css.html HTTP/1.1
PageSpeed: on
PageSpeedFilters: rewrite_css

Query parameters can be added to the URL of the page or resource being fetched, request headers can be set in the request for pages and resources, and response headers can be set in the response of HTML pages (but not resources). These settings affect only the given request. If all three (query parameters and both headers) are used in the same request the query parameters will be applied first, followed by the request headers, followed by the response headers. Later settings override earlier settings but a filter disable in any location always overrides subsequent enables.

There are two supported methods of adding response headers that PageSpeed will be able to observe and process. The first is to add response headers with a content handler such as ASP.NET or Cold Fusion. The second is to add response headers at an origin server and run PageSpeed as a proxy in front of it.

Enabling and disabling PageSpeed

Query parameters:


Request & Response headers:


Specifying the filters applied

Query parameters:

PageSpeedFilters=comma-separated list of names

Request and Response headers:

PageSpeedFilters: comma-separated list of names

This specifies the set of filters to apply to the page. The list of settings includes all filter names and a few shortcut names:

  • core sets the rewrite level (per RewriteLevel) to CoreFilters. This enables the core set of filters.
  • testing enables all filters that are in the TestingCoreFilters level but are not in the CoreFilters level - this is not the same as setting the level to TestingCoreFilters because that includes all core filters, but the same effect can be achieved by specifying both: core,testing.
  • rewrite_images enables the following filters: inline_images, recompress_images, and resize_images.
  • extend_cache enables the following filters: extend_cache_css, extend_cache_images, and extend_cache_scripts.
  • rewrite_javascript enables the following filters: rewrite_javascript_external and rewrite_javascript_inline.

When any filter is specified without a "+" or "-", any filters not explicitly enabled are disabled. Filters and shortcuts can be explicitly disabled by preceding the name by a minus sign ('-'), which is useful after using a shortcut. For example, "core,-combine_css" enables all the core filters except combine_css.

If all names are prefixed with "+" or "-" then the filter set is incrementally adjusted from the current system settings based on the configuration files. For example, in a server with RewriteLevel set to CoreFilters, the query-string


will leave all the core filters enabled, but will add lazyload_images and disable inline images.

Sticky Query Parameters

Query parameters can be set to be "sticky" and persist across requests using cookies. Sticky query parameters can be set by providing the sticky query parameter option in a request, and the server will respond with a cookie, valid for the duration specified in the PageSpeed configuration.

To prevent abuse, a "secret token" must be provided in the initial request to enable setting cookies.

pagespeed StickyQueryParameters example_token

The duration, in milliseconds, for which the cookie will be valid can be set in the PageSpeed configuration.

pagespeed OptionCookiesDurationMs 360000

The request must specify the token in a query parameter, for example:


A request with the correct token will be cookied to persist the options. In the example above, the remove-comments filter would be enabled.

Tweaking Inlining Limits

Query parameters:


Request & Response headers:

  PageSpeedCssFlattenMaxBytes: value
  PageSpeedCssImageInlineMaxBytes: value
  PageSpeedCssInlineMaxBytes: value
  PageSpeedImageInlineMaxBytes: value
  PageSpeedJsInlineMaxBytes: value

These specify the limits for the following inlining options:

  • PageSpeedCssFlattenMaxBytes sets the maximum size of CSS files that will be flattened.
  • PageSpeedCssImageInlineMaxBytes sets the maximum size of images inside CSS. For inline CSS in HTML files, the value used is the smaller of this value or PageSpeedImageInlineMaxBytes.
  • PageSpeedCssInlineMaxBytes sets the maximum size of CSS files that will be inlined.
  • PageSpeedImageInlineMaxBytes sets the maximum size of image files that will be inlined.
  • PageSpeedJsInlineMaxBytes sets the maximum size of JavaScript files that will be inlined.

Here is an example that combines many of the above query parameters to enable all the core filters except the cache extension filters, and sets the JavaScript inlining limit to a high value so that most JavaScript files will be inlined:


Client options in queries and headers

This is an experimental option, its name and values are subject to change. This option allows the client to customize the optimizations applied to a request and can be used in a header or query parameter.

As a query parameter:


As a Request or Response header:

X-PSA-Client-Options: client-options

The format of client-options is

  name1=value1,name2=value2, …

The order of the name-value pairs does not matter. The supported options are:


Version of the header. '1' is the only supported version for now.


Mode. Valid values are

  • 0, the client prefers that the server operates in its default mode.
  • 1, the client prefers that no image is transformed.
  • 2, the client prefers that no resource is transformed. This is equivalent to "?PageSpeedFilters=" in the request URL

Image quality preference. Valid values are

  • 0, the client prefers that the server uses its own default image quality.
  • 1, the client prefers low image quality.
  • 2, the client prefers medium image quality.
  • 3, the client prefers high image quality.

Restrict per-request configuration

Note: New feature as of IISpeed 2.0

Interpretation of PageSpeed query parameters and headers can be restricted to requests specifying a request option override token. The token is specified in the server configuration file and disallows request option overriding when the request does not specify the correct token. This option can be used to reduce the attack surface of denial of service attacks.

pagespeed RequestOptionOverride example_token

This feature provides a mechanism to restrict the ability for filters and options to be specified in query parameters and request headers. To enable it, an override token must be specified in the configuration file, and requests must specify the same token for filters and options to be applied. Query parameters, except for PageSpeed=on, PageSpeed=off, or PageSpeed=noscript will then only be interpreted when accompanied by the correct RequestOptionOverride token. For example, the rewrite_css filter would be used in this example.

The request must specify the token in a query parameter or header, for example:


Any request not containing the correct RequestOptionOverride token or not containing a RequestOptionOverride token will ignore all other PageSpeed filters and options specified.

Note: even if applied, PageSpeed=on|off|noscript still takes effect.

Share View Comments
Some content on this website represents a modified version of the official Google PageSpeed documentation