Intermittently after enabling mod_pagespeed you may find that images and other resources on your website go missing, are broken, and show 404 errors.
You may find warnings similar to the following within the Apache error log. Note that these 4 errors are slightly different, but are caused by the same issue:
[Thu Mar 11 21:43:12.750371 2021] [pagespeed:warn] [pid 28240:tid 47892692387584] [mod_pagespeed 184.108.40.206-0 @28240] https://exampledomain.tld//xfilename.jpg.pagespeed.ic.vwPdVLxCzq.webp resource_404_count: not found (404)
[Thu Mar 11 21:43:12.751185 2021] [pagespeed:warn] [pid 28240:tid 47892698691328] [mod_pagespeed 220.127.116.11-0 @28240] Fetch failed for https://exampledomain.tld/filename.jpg.pagespeed.ic.B2rCBEDGj1.webp, status=404
[Thu Mar 11 21:43:12.752867 2021] [pagespeed:warn] [pid 28240:tid 47892830193408] [mod_pagespeed 18.104.22.168-0 @28240] filename.jpg:0: Resource based on https://exampledomain.tld/filename.jpg but cannot access the original
[Thu Mar 11 21:43:12.752922 2021] [pagespeed:warn] [pid 28240:tid 47892830193408] [mod_pagespeed 22.214.171.124-0 @28240] [0311/214312:WARNING:resource_fetch.cc(195)] Fetch failed for resource url https://exampledomain.tld/filename.jpg.pagespeed.ic.ZYQLHswKUe.webp
You may also find messages similar to the following within the HTML of your site if you turn on debug output for mod_pagespeed:
4xx status code, preventing rewriting of https://exampledomain.tld/css/example.min.css
If you'd like information about how to enable debug output in the HTML of your site please see the following resource:
You may also notice that there are no traces of the mod_pagespeed fetcher anywhere in the Apache access logs. If you'd like information about how you can search for the fetcher in the access logs, please see the following resource:
The last and potentially most important thing to note when diagnosing this particular issue is that all of the problematic URLs in the error messages above are using TLS/SSL via HTTPS, rather than HTTP.
This problem occurs because mod_pagespeed is not able to access the HTTPS urls of your site.The specific reason that the fetcher is not able to access HTTPS urls on your server can vary widely.
If you want to know the exact reason that the fetcher is not able to access HTTPS urls for your site, you'll need to work with a systems administrator to fully review the issue and provide a diagnosis for your specific situation. The following workaround section offers some suggestions.
PageSpeed does not fetch HTTPs URLs by default. If your website redirects HTTP requests to HTTPs, you'll need to customize the configuration to enable the HTTPs fetcher.
Open the /etc/apache2/conf.modules.d/510_pagespeed.conf file with a text editor of your choice.
Add the following to the bottom of the configuration file:
You must then restart Apache for the change to take effect with the following command:
It is also possible that you continue to have this problem even after enabling the HTTPs fetcher. This could be caused by a number of various problems. Adding additional options to the configuration may workaround some problems with your site's certificate:
This configuration is specifically explained in the official documentation here:
If you're unsure where the configuration file is, you can learn here:
You may also want to purge the mod_pagespeed cache after updating the configuration: