Rewrite Domains
Configuration
The 'Rewrite Domains' filter is enabled by specifying:
- Apache:
ModPagespeedEnableFilters rewrite_domains
- Nginx:
pagespeed EnableFilters rewrite_domains;
in the configuration file. The filter is not enabled by default and should be added manually to the configuration file.
By default rewrite_domains
only applies to resources, but it can
optionally rewrite domains in hyperlinks as well:
- Apache:
ModPagespeedDomainRewriteHyperlinks on
- Nginx:
pagespeed DomainRewriteHyperlinks on;
Description
This filter applies all domain mapping
directives specified in pagespeed.conf to web resources that
are not otherwise rewritten by PageSpeed. For
example, if a resource is not cacheable, or filters which affect the
resource are turned off, then it still may be desirable to apply
domain sharding. (Domain sharding is not applied to hyperlinks even if DomainRewriteHyperlinks
is enabled.)
Requirements
It is the responsibility of the site administrator to set up the shard entries in their DNS or CNAME configuration. Also, please see the note about the servers for rewrite domains — this applies to sharded domains as well. The sharded domains must have access to the same content as the original domain.
Risks
It is the responsbility of the site administrator to ensure that moving resources onto domains does not create a security vulnerability. In particular, if the target domain has cookies, then any JavaScript loaded from a resource moved to a domain with cookies will gain access to those cookies. In general, moving resources to a cookieless domain is a great way to improve security. Be aware that CSS can load JavaScript in certain environments.