We were trying to optimise the website using google pagespeed and now having some issue:
We're using nginx_pagespeed module Trying to enable the prioritize_critical_css filter Since the CSS files are loading from external CDN domain, the critical css filter is not working. When ran with the ?PageSpeedFilters=debug, the following error is generated in the html source
Summary computation status for CriticalCssBeacon
Resource 0 https://mycdndomain.com/styles/screen-2d470013.css: Cannot create resource: either its domain is unauthorized and InlineUnauthorizedResources is not enabled, or it cannot be fetched (check the server logs)
Where mycdndomain is our CDN domain.
Can someone help me fixing this issue. What nginx pagespeed configuration changes are required ?
Also what is the InlineUnauthorizedResources ?
By default, mod_pagespeed only rewrites resources on the same domain as the HTML, to enable rewriting resources on other domains you need to explicitly authorize rewriting and maybe do some configuration.
Most simply, you can authorize a domain for rewriting with the pagespeed Domain
declaration:
pagespeed Domain https://mycdndomain.com;
This will instruct mod_pagespeed to rewrite resources from that domain.
But be careful, this just instructs mod_pagespeed to rewrite the URLs, you will have to make sure that your CDN can serve the rewritten URLs! If it just pulls the content from your server, this should be fine, but if it's a push CDN, it will break when you change the URLs.
See https://developers.google.com/speed/pagespeed/module/domains for a full description of authorizing and mapping domains.