Rewriting Level
mod_pagespeed offers two default "levels" to simplify configuration:PassThrough and CoreFilters. The CoreFilters set contains filters that the mod_pagespeed team believes are safe for most web sites. By using the CoreFilters set, as mod_pagespeed is updated with new filters, your site will get faster. To disable the
CoreFilters, you can specify ModPagespeedRewriteLevel PassThroughand then enable specific filters with the ModPagespeedEnableFilters directive. The default level is
CoreFilters. The core set of filters is set to:add_head combine_css extend_cache inline_css inline_javascript insert_img_dimensions rewrite_images trim_urls
Enabling and Disabling Specific Filters
To turn off specific filters in the core set, specify:ModPagespeedDisableFilters filtera,filterbFor example, if you want to use the core set of filters, but specifically disable
rewrite_images and combine_css, you can use: ModPagespeedDisableFilters rewrite_images,combine_cssThe
ModPagespeedEnableFilters configuration file directive allows specification of one or more filters by name, separated by commas. You can use any number of ModPagespeedEnableFilters directives, each of which can contain multiple filter names separated by commas. For example: ModPagespeedRewriteLevel PassThrough
ModPagespeedEnableFilters combine_css,extend_cache,rewrite_images
ModPagespeedEnableFilters rewrite_css,rewrite_javascriptThe order of the directives in the configuration file is not important: the rewriters are run in the pre-defined order presented in the table: | Filter name | In Core Set | Brief Description |
add_head | Yes | Adds a <head> element to the document if not already present |
combine_heads | No | Combines multiple <head> elements found in document into one |
strip_scripts | No | Removes all script tags from document to help run experiments |
outline_css | No | Externalize large blocks of CSS into a cacheable file |
outline_javascript | No | Externalize large blocks of JS into a cacheable file |
move_css_to_head | No | Moves CSS elements into the <head> |
combine_css | Yes | Combines multiple CSS elements into one |
rewrite_css | No | Rewrites CSS files to remove excess whitespace and comments |
make_google_analytics_async | No | Convert synchronous use of Google Analytics API to asynchronous |
rewrite_javascript | No | Rewrites Javscript files to remove excess whitespace and comments |
inline_css | Yes | Inlines small CSS files into the HTML document |
inline_javascript | Yes | Inlines small JS files into the HTML document |
rewrite_images | Yes | Optimizes images, re-encoding them, removing excess pixels, and inlining small images |
insert_img_dimensions | Yes | Adds width/height attributes to <img> tags that lack them |
remove_comments | No | Removes comments in HTML files, though not inline js or css |
trim_urls | Yes | Shortens URLs by making them relative to the base URL |
collapse_whitespace | No | Removes excess whitespace in HTML files (avoiding <pre>, <script>, <style>, and <textarea>) |
elide_attributes | No | Removes attributes which are not significant according to the HTML spec |
extend_cache | Yes | Extends cache lifetime of all resources by signing URLs with content hash |
remove_quotes | No | Removes quotes around HTML attributes that are not lexically required |
add_instrumentation | No | Adds JavaScript to page to measure latency and send back to the server |
Tuning the Filters
Once the rewriters are selected, some of them may also be tuned. These parameters control the inlining and outlining thresholds of various resources.ModPagespeedCssInlineMaxBytes 2048
ModPagespeedImgInlineMaxBytes 2048
ModPagespeedJsInlineMaxBytes 2048
ModPagespeedCssOutlineMinBytes 3000
ModPagespeedJsOutlineMinBytes 3000Note: The default settings are reasonable and intuitive, but as of this writing (Feburary 2011) have not been experimentally tuned.
These directives can be used in .htaccess files and <Directory> scopes.
No comments:
Post a Comment