mod_pagespeed combine css on other domain

2019-07-30 14:56发布

问题:

I've been looking at mod_pagespeed as a way to speed up my site. I currently load my CSS/JS from a separate domain to speed up loading of those resources. However, I like to break up my CSS/JS into useful functional chunks. This means, in the worst case scenarios I may have half a dozen CSS files and the same number of JS files being included on a single page.

So my question is. How can I use mod_pagespeed to continue loading files from a different domain but also use the combine_css/combine_js directives?

回答1:

Yes, but you either need to run mod_pagespeed on both sites (and authorize both sites) or to rewrite the CSS/JS from the other domain to the one that runs mod_pagespeed.

For example, if you have mod_pagespeed installed on both your main site (http://www.example.com) and your static-content site (http://static.example.com), you can add:

ModPagespeedDomain http://static.example.com

to your pagespeed.conf file on www.example.com and this will authorize mod_pagespeed to rewrite those resources and continue to serve them from that domain. See http://code.google.com/speed/page-speed/docs/domains.html#auth_domains for doc.

If you want mod_pagespeed to rewrite resources from your static domain to your main domain you can add:

ModPagespeedDomain http://static.example.com
ModPagespeedMapRewriteDomain www.example.com static.example.com

which will tell mod_pagespeed to rewrite files in static.example.com and move them to www.example.com.

If you have more questions, feel free to contact us on our official email list: https://groups.google.com/group/mod-pagespeed-discuss

-Shawn Ligocki (mod_pagespeed team)