Mod-PageSpeed support for multiple domains on WordPress
We are hosting hundreds of websites on multiple hosts in AWS, and are trying to correctly configure the Apache Mod-PageSpeed. The issue we have is the following: since the list of hosted websites is dynamic, whitelisting them one by one in the configuration using ModPagespeedDomain isn’t a solution.
So in our test, for now, we are using ModPagespeedDomain *. As a result, other domains are obviously failing, since the websites end up having resources like http://example.com/main.css.pagespeed.cf.eq3E2z30Fz.css, where http://example.com/main.css does exist, but the target website doesn’t have mod-pagespeed.
I have the following two ideas, but didn’t manage to make neither work:
- Rewrite all resources to the main domain. I have tried ModPagespeedMapRewriteDomain, ModPagespeedMapProxyDomain and ModPagespeedMapOriginDomain but I didn’t manage to make it work properly (outside domains are still fetched from their origin). Ideally, following the previous example, http://example.com/main.css is fetched, optimized, and served from our servers directly.
- Only work on the requested domain, if that’s possible, but I didn’t find out how. So if abc.com is requested, all resources in the page pointing to abc.com would be optimized and not others, and if it’s abd.com, then only the ones to abd.com.
- The last resort is to block all outside domains, which isn’t ideal either to be able to easily add new dependencies.
Open for any idea / suggestion. Thank you! Charles