Restricting Rewriting Via Wildcards: ModPagespeedDisallow and ModPagespeedAllow
By default, all HTML files served by your server and all resources (CSS, images, JavaScript) found in HTML files whose origin matches the HTML file, or whose origin is authorized via ModPagespeedDomain, will be rewritten. However, this can be restricted by using wildcards, using the directives:ModPagespeedAllow wildcard_spec ModPagespeedDisallow wildcard_specThese directives are evaluated in sequence for each resource, to determine whether the resource should be consider for rewriting. This is best considered with an example.
Example 1: Excluding JavaScript files that cannot be rewritten
Some JavaScript files are sensitive to their own names as they traverse the DOM. Therefore any rewriting on these files is invalid. We cannot cache-extend them or minifiy them. When such files are identified, we can exclude from the rewriting process via:ModPagespeedDisallow */jquery-ui-1.8.2.custom.min.js ModPagespeedDisallow */js_tinyMCE.js
Example2: Specifying explicitly which types of files can be rewritten
By default, every resource referenced by HTML from authorized domains is rewritten, as if there was an implicitModPagespeedAllow *at the beginning of every configuration. To change the default to be exclusive, issue
ModPagespeedDisallow *and then follow it with which files you want to include. For example:
ModPagespeedDisallow * ModPagespeedAllow http://*example.com/*.html ModPagespeedAllow http://*example.com/*/images/*.png ModPagespeedAllow http://*example.com/*/styles/*.css ModPagespeedDisallow */images/captcha/*The later directives take priority over the earlier ones, so the Captcha images will not be rewritten.
Note: Wildcards include
These directives can be used in * which matches any 0 or more characters, and ?, which matches exactly one character. Unlike Unix shells, the / directory separator is not special, and can be matched by either * or ?. The resources are always expanded into their absolute form before expanding. .htaccess files and <Directory> scopes. Note: The names in wildcards are not evaluated with respect to the
<Directory> scope or the directory containing the .htaccess file. The wildcards are evaluated against the fully expanded URL. So if you want to match js_tinyMCE.js you must prefix it with its full path, including http:// and domain, or use a wildcard, as shown above. Restricting mod_pagespeed from combining resources across paths
Note: New feature as of 0.9.15.1
By default, filters that combine multiple resources together are allowed to combine multiple resources across paths. This works well much of the time, but if there are Apache directory-level access controls, or path-specific cookies associated with JavaScript files, then you may need to turn off this feature.ModPagespeedCombineAcrossPaths offThese directives can be used in
.htaccess files and <Directory> scopes. Limiting the maximum generated URL segment length
Note: New feature as of 0.9.15.1
The maximum URL size is generally limited to about 2k characters due to Internet Explorer: See http://support.microsoft.com/kb/208427/EN-US. Apache servers by default impose a further limitation of about 250 characters per URL segment (text between slashes). mod_pagespeed circumvents this limitation, but if you employ proxy servers in your path you may need to re-impose it by overriding the setting here. The default setting is 1024.ModPagespeedMaxSegmentLength 250These directives can be used in
.htaccess files and <Directory> scopes.
No comments:
Post a Comment