After configuring the Page Speed API Key in W3 Total Cache plugin in order to retrieve and view Google Page Speed Report from within the WordPress dashboard, the following error message is displayed in Google Page Speed dashboard widget:
Unable to fetch Page Speed results.
The error normally happens when PageSpeed Insights API key is set to have key restriction based on HTTP referrers (web sites). When the Google API key is blocked from been used by incoming requests, the error ratio and error count shown on the Google API Manager console steadily increased with every refresh on the Google Page Speed Report widget.
As mentioned above, the cause for the “unable to fetch Page Speed results” error is most likely due to misconfiguration of API key restriction.
To resolve the issue, visit the Credentials of Google API Manager at https://console.developers.google.com/apis/credentials (make sure you select the project which the API key is used in W3TC).
Click or tap on the Edit (pencil) icon at the end of the API key. Under “Key restriction” section, select IP addresses (web servers, cron jobs, etc.), and then enter the IP addresses of web server that hosts the website and makes the Google PageSpeed requests to Google.
If for some reason you cannot set the key restriction to be based on IP addresses, you can try the following workaround. W3 Total Cache doesn’t seem to properly set the referrer in HTTP/HTTPS request header, and as the result, blocking by HTTP referrer is almost certainly to fail. To make it works, try to add the following line to HTTP referrers (web sites) option:
The worst case scenario is to remove all key restriction by selecting None, but this workaround will make the API key unrestricted, which may accidentally expose the API key to unauthorized use and quota theft.