Static assets take 6 min to load


#1

Hi,

We have a web application set up to be accessed via Cloudflare.

Every now and then a full load of the site is negatively impacted by the slow loading of static assets, being of type JavaScript, image or CSS-file. Most often when this happens in a full page reload there is only one asset file that is loading slowly, as seen in the attached screen shot. We have, however, also seen examples of 2 asset files loading very slowly simultaneously, but this is not the general rule. Not every full page load is impacted, but it does happen all too often nonetheless.

Also it seems that the asset does finally load, and often the time to load is of the order of 6 min. To me this suggests some timeout limit of 6 min is reached at server cache side and a new subsequent attempt is then successful.

And if a full page reload is impacted, then usually the next full page reload occurs successfully.

We have tried to temporarily bypass Cloudflare for our site. Our impression is that in this configuration the slow loading of static assets does not happen. However, given that we also don’t see slow loading of static assets in every full page load when accessing via Cloudflare, our impression of the state when bypassing Cloudflare may indeed be wrong.

FYI our site is developed with Node.js and Express and runs on AWS EC2 with Elastic Load Balancer in front. Our load balancer instance allows inbound HTTP and HTTPS request on ports 80 and 443, respectively, from IP addresses as specified in https://www.cloudflare.com/ips/.

One more thing to add. We tried out the caching of all assets as described in https://support.cloudflare.com/hc/en-us/articles/200172256-How-do-I-cache-static-HTML-.

After having configured, purged the Cloudflare cache and waited we now see from the log of our web application that server side is not hit with new requests, indicating indeed that all assets are retrieved from the Cloudflare cache.

Even with this last setup we find that certain files every now and then load only after 6 min. Which file that loads slowly at any full page load seems to be pretty random.

Is anyone able to shed some light on the reason for our experienced intermittent slow loading of static assets?

Regards,
Jens Ivar


#2

No screenshot, do you have a link? If you try to curl that same object during this time period does the object show as a hit from Cloudflare’s cache? curl -I http://example.com/image.jpg

Are these objects that are returning a 404 and that’s what you mean by slow to load? We do cache 404 responses for 5 minutes. If the origin returns a 404 for an asset we wont check again to see if it is updated for 5 mins.


#3

Hi,

The site is at https://www.hubii.network.

Trying to reproduce the problem right now I got the following example:

I then curl the first asset, the png image, while it is still pending in the browser and obtain the response provided below:

> curl -I https://www.hubii.network/images/logo/Hubii_Network_Logo_Invert_L.png
HTTP/1.1 200 OK
Date: Thu, 20 Jul 2017 16:33:27 GMT
Content-Type: image/png
Content-Length: 77930
Connection: keep-alive
Set-Cookie: __cfduid=df8779cc064007223001f8e28f4f50e081500568407; expires=Fri, 20-Jul-18 16:33:27 GMT; path=/; domain=.hubii.network; HttpOnly
Cache-Control: public, max-age=0
ETag: W/"1306a-15d33d15b34"
Last-Modified: Tue, 11 Jul 2017 22:42:24 GMT
X-Powered-By: Express
CF-Cache-Status: HIT
Accept-Ranges: bytes
Server: cloudflare-nginx
CF-RAY: 381752841ea042af-OSL

The loading of the assets finally completes after about 6 mins. (As I am new user with 1 image per post constraints on this site the screenshot of this follows in new post below.)

Repeating the curl operation on the png image after the loading completed in the browser in my eyes is not significantly different:

> curl -I https://www.hubii.network/images/logo/Hubii_Network_Logo_Invert_L.png
HTTP/1.1 200 OK
Date: Thu, 20 Jul 2017 16:40:15 GMT
Content-Type: image/png
Content-Length: 77930
Connection: keep-alive
Set-Cookie: __cfduid=d3efbc579fa69c4b797990183f4d3cf821500568815; expires=Fri, 20-Jul-18 16:40:15 GMT; path=/; domain=.hubii.network; HttpOnly
Cache-Control: public, max-age=0
ETag: W/"1306a-15d33d15b34"
Last-Modified: Tue, 11 Jul 2017 22:42:24 GMT
X-Powered-By: Express
CF-Cache-Status: HIT
Accept-Ranges: bytes
Server: cloudflare-nginx
CF-RAY: 38175c789a4f429d-OSL

In other words client side there is no sign of 404s. Do you think however that 404s at Cloudflare’s end can explain what we see in our browsers?

Jens Ivar


#4

Here is the image indicating the completed loading of the 2 assets in my post above:

Jens Ivar


#5

No issue when I visit. Have you considered turning on HTTP/2?


As a side note, your 404 page loads a lot of Javascript and css files that result in not found. Some of these files aren’t really needed. (Countdown, for example, only needs to be loaded on pages with a countdown - not the 404 page).
eg: https://www.hubii.network/images/ loads https://www.hubii.network/images/css/* , but should load https://www.hubii.network/css/*

:grinning:


#6

Hi. I tested your site from a variety of locales and didn’t appreciate any extended load times - certainly nothing near 6 minutes.

I don’t want to throw things off track but a few things stood out to me when analyzing the waterfall:

  • Cache-Control header is set to ‘max-age=0’ for most assets
  • There is no ‘expires’ header for most assets

If the Cache-Control header is set to “private”, “no-store”, “no-cache”, or “max-age=0”, or if there is a cookie in the response, then Cloudflare will not cache the resource, unless a Page Rule is set to cache everything and an Edge Cache TTL is set.

I do see CF-Cache-Status: HIT in the response headers though, so you must be using a page rule… In general I am curious how you have your Cache settings configured, but that doesn’t really seem to be related to your current issue.

Anyway your site loads just fine for me, even on mobile :smiley:


#7

@jensivar

Can you post the colo you are hitting for your site when testing (info on how to obtain in the link below). Like the others, it seems to be loading fine for me, so want to see if knowing the colo can shed any light.


#8

Try using https://www.webpagetest.org/ to open side from different parts of world and see it requests open instantly or not.


#9

We’re experiencing the same problem! Found this stackoverflow question describing my problem pretty good, but the solutions in the question did not really help us.

Our issue is that some static asset files are taking from 40 seconds to 6 minutes to load. It is not the same file every time, we’ve noticed around 10 different files being slow to load. The response from cloudflare shows a cache HIT, so the file should be cached. It’s almost always one single file which is causing problems (some times two), and if that file is an important .css or .js file the whole website is blocked. Our problem can be reproduced by hard refreshing the website (clearing local cache, or with “Disable cache” in chrome developer tools) around 5-15 times. We have never been able to reproduce the problem when bypassing cloudflare and going directly to heroku (where our site is located).


#10

Our website is https://web.cgp-data-services.com/


#11

Same problem here. Some requests just take up to 6 minutes to process. Logs on server for such a requests to non-static files show generation on normal speed (150-200 ms maximum), so this is definitely not a problem on my server side. Cloudflare support just keeps silence for almost a week now.
Did anybody tried to ask support regarding this problem. Maybe there is a solution?


#12

Any news about this issues? we have same issues. some of asset load so slow, but it doesn’t happen all the time. we made some test, and we can conclude this issues is on cloudflare cache. when we try to access (both asset & dynamic content) directly using IP its working.


#13

Received an answer in support ticket just a few hours ago. They just asked me if the problem is still there. It is. Waiting for their next response. Didn’t find solution on my side aside from disabling Cloudflare, but this is not the thing I would like to do.


#14

Do you have a ticket number I can look up?


#15

Yes, here it is: #1400149


#16

We filed a support ticket with Cloudflare, https://support.cloudflare.com/hc/en-us/requests/1382331. I believe the most important piece was to disable Rocket Loader which we had on at that time.


#17

The thing is we don’t have Rocket Loader enabled. And support is silent for another week after asking for more data… Hope the problem will resolve in near future.


#18

I’m checking on this now. Not sure what may have caused the delay, but you should get a response today.


#19

Having exactly the same issue right now. Random cache HIT assets taking a very long time. I’m too getting the same timings very often, like around 60s or 6min, indicating some sort of a timeout. This is happening on both my domains that are under CloudFlare. No extra stuff is enabled, just standard caching. I’m hitting FRA colo. Created a ticket #1410173, provided test info, still waiting for a response.

I can also reproduce the problem just by requesting any single asset in a loop, usually around 100 requests are enough:
for i in {1..100}; do curl -w "%{time_total}\n" -o /dev/null -s "https://domain/path-to-the-asset"; done

Funny thing is, that I’ve tested this with other sites that I know use CloudFlare, and I can’t reproduce it, even though I’m hitting the same colo.


#20

My ticket will reach a month from opening in a few days and for all this time I’ve been few times asked to provide HAR files. Again and again, starting to lose hope of this bug to be ever fixed.