mod_pagespeed combine css on other domain

送分小仙女□ 提交于 2019-12-24 08:23:54

问题


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)



来源:https://stackoverflow.com/questions/8885632/mod-pagespeed-combine-css-on-other-domain

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!