I am running speed/optimization tests on my wordpress site and when CF is enabled, every single one of my scripts are loading twice and it’s killing my loading time. When I PAUSE CF it loads normal. I have been trying to toggle CF options on/off but can’t narrow down the issue.
I am hosting a wordpress site and this is the coverage on page loading while CF is on, with CF paused each of these scripts will only load once…
I can also tell it loads twice because when opening a new page, it begins to load then flashes and quickly reloads again. If your on the page scrolling down it will bring you back to the top like a refresh almost.
Yes, it loads fine with CF paused - only happens with CF enabled
Thanks Sandro, disabling Rocket Loader / clearing cache was the first things I tried… I am seeing the discrepancy between pagespeed and browser as well… not sure what to make of it but I was trusting my eyes with the double load because I could actually see it happen
If there are such content issues, it usually is Rocket Loader. Apart from that Cloudflare tunnels content more or less one-to-one. If you can’t reproduce it locally, it will be difficult to debug, as there is no further insight provided by web.dev.
Just to verify, you do not have any Workers running for your domain or any Cloudflare applications configured, right?
Maybe web.dev ran on some cached version. I’d clear the Cloudflare cache and try a brand-new run on web.dev. Enable development mode on Cloudflare before that, to avoid caching and correlate the requests in your server log.
If you do not have Rocket Loader enabed, the issue should really not be Cloudflare related at this point.
I followed your instructions and after some testing I learned via my server error logs that CF is triggering Mod Security (web application firewall) error with my server hosted on Dreamhost. I tested with Mod security both ON and OFF and the result was the same… As long as CF is on the double loading appears.
That seems to be a warning though, not an error. While Cloudflare generally does only tunnel requests, the request is still a new one, so it is possible that request would be slightly different from the browser request and that fires a mod_security rule on your end. I’d debug that to find out what exactly fire that rule, however that should still not execute requests twice.
As mentioned, it does not seem reproducible in a browser and that suggests it may be an issue with web.dev. But even if the browser requests a file twice, that would be because your site requests it twice, Cloudflare can’t tell the browser to do that.
Hey, you were absolutely right! Can’t believe I didn’t think of this earlier. So, I ran my performance test through GTmetrix and another alternative, and the performance was stellar. There were no issues with scripts double loading. The inability to reproduce the double scripts in the browser, along with the two alternative speed testing sites showing the same, I think is strong enough evidence to come to the conclusion that it is a page speed error. I’ve been relying on page speed insights for so long, and I never thought it would have me chasing my tail like this.
Thanks Sandro for taking the time to help and sharing your knowledge. I’ve learned so much from you in this thread and I agree - you are the MVP!