I've been hunting down 404 problems with css files for a while now and I finally have it nailed down. I originally thought it was related to sharding (and to be sure, we had problems with our configuration there), but now I'm pretty sure it's a bug in pagespeed:
Version: 1.12.34.2
While optimizing a css file that references many other images, pagespeed is 404'ing subsequent requests for that resource.
Specifically:
* Starting pagespeed with a clean cache.
* Make a request for A.megahuge.css.pagespeed.cf.Ut0KGaDYUK.css
* Pagespeed fetches the original megahuge.css and starts downloading and optimizing the dependent resources.
* The original request for A.megahuge.css.pagespeed.cf.Ut0KGaDYUK.css times out after a few ms and returns the original resource with a short cache expiration.
--- so far, so good ---
* A second request for A.megahuge.css.pagespeed.cf.Ut0KGaDYUK.css comes in. That gets stuck waiting in ResourceFetch::BlockingFetch for the callback to complete.
* Pagespeed continues working on optimizing the dependent resources from the first request.
* After 5 seconds, the BoundedWaitFor call in ResourceFetch::BlockingFetch gives up, and pagespeed returns a 404 (!) for the resource.
In this case, the css file takes several minutes to optimize, so we have tons of these 404's until somebody gets lucky and the CDN caches the optimized result.
It's even worse if the css file takes so long to optimize that pagespeed decides to refresh the content before serving the optimized result.
So, I've traced the code through and through to nail it down to this BoundedWaitFor call. How can I fix the problem? I want the same behavior as the original request: If the callback hasn't completed within a few ms, then return the un-optimized resource.
- Augusto