Slow asset load time

Archived from the Transloadit support forum. Originally posted on June 5, 2011; details may be outdated, see our docs for current behavior. Original thread

It seems that jquery.transloadit2.js is being served from Amazon, but not cloudfront? That means it’s being served from US servers no matter where you’re requesting it from. For me, a European customer, it’s adding about 100 ms just in latency as it has to travel across ‘the pond’. This averages out to about 200ms for every request. For a single js file of 6.4kb, that’s quite disproportionate.

Is there a particular reason for not letting Amazon’s cdn take care of it?

Hi Ben,

I think the main reason we decided to go against cloudfront for distributing our jquery plugin is that cloudfront does not let you use your own https certificate, thous ruling out using a cname for the domain, see:

http://stackoverflow.com/questions/5164569/cloudfront-serving-over-own-ssl-certificate

The other reason was that we assumed that the upload page is not as performance critical as other areas. Or in other words, if you load the plugin in the background (by putting it at the end of your body), the user experience is not impacted unless somebody manages to select and submit a file in < 200ms.

That being said, we’d certainly love to host the plugin on a CDN. But as things look right now, we’ll probably wait for Amazon to catch up.

Let me know if that makes sense / is good enough for now.

--fg

PS: Alternatively you could self-host the plugin, but this means that you’re responsible for keeping it updated - it’s certainly not the preferred way.

Hi Felix,

Ouch, that’s quite surprising to hear, and reading up on it makes me cringe at how long it’s taken them to implement the basics.

I’ve hosted it myself in the past, but ran into issues when it got updated without me noticing it, so I’m trying to avoid that.

You’re right that in most situations, it is not really a big deal though. However, with IE not allowing multiple file uploads, some of our customers have to upload all their images one by one. So, if they upload 50 images, that comes down to an extra 10 seconds, just for the js file. And since most of the added time is pure latency, that means even a cached version doesn’t help.

That being said, I’m quite happy to hold out for a solution, I mainly wanted to know your thoughts on the matter.

So, if they upload 50 images, that comes down to an extra 10 seconds, just for the js file.

So you’re saying our plugin is not being cached? Maybe we can set an expires header (24 hours?) for now?

That being said, I’m quite happy to hold out for a solution, I mainly wanted to know your thoughts on the matter.

Yes, once cloudfront adds this feature we’ll use it for delivery. Meanwhile maybe the caching idea above could work?

It is cached, but it’s checking for modification, this means having to talk to the server in the US, adding anything between 100 to 500 ms (yes it varies a lot).

GET jquery.transloadit2.js 304 Not Modified 105ms

The problem ultimately lies with the “max-age” header I believe:

Cache-Control max-age=0

This header means it will always revalidate against the server for modification. Setting max-age to an hour would validate against the server on the first request and get the file straight from disk for the next 60 minutes. Without checking for modification.

However, if any breaking changes are introduced, you risk having some users with a non-functioning js file.

However, if any breaking changes are introduced, you risk having some users with a non-functioning js file.

Well, we would have to remove the max-age well ahead of deploying a new version, so yes - forgetting about this would be painful.

So if the situation is ok for now on your end, I’d prefer to leave things as they are. Otherwise I can make this change for you.

--fg

No, that’s quite alright, I’ll wait for Amazon to allow the certificates.

I’m still young, it’ll happen eventually :wink:

Hey Ben,

We went ahead and deployed a 1 hour expire header for our jquery plugin.
Let me know if this indeed enhances the experience in your application.

Hi Kevin,

Excellent! It’s now coming from cache on consecutive loads. Thanks a lot for making the effort, I hope nobody runs into any issues because of it.

Alright, closing this.