Moving JAVASCRIPT and CSS to a CDN for improved global delivery

Hello all.
As FoxyCart users continue to grow and use FoxyCart on larger sites it's obviously increasing the load on our servers. Also, due to PCI compliance requirements, we are limited in certain ways, especially in regard to cloud hosting.

So, up to this point, the foxycart_includes.js files have dynamically served up the correct version of the file based on the store version (from the host in the request). This has worked, but:
-- Every request hits our servers, in the US, so it can be slower in Australia (notably) and elsewhere.
-- Every request pushes our servers a little more towards capacity, increasing our costs (and eventually our prices).
-- When our app servers go down, this creates problems if the files are included in the <head> of your sites. While we have very solid uptime, nobody's perfect.

In order to get around these issues we're looking at using a Content Delivery Network (CDN), which basically is a way to host files all around the world. This should _radically_ improve load times for those files as well as reduce our system load, allowing us to keep our costs as low as possible for you all.

The potential downside is that CDNs are "dumb", so if you're on v060, the CDN won't know. You'll have to enter a different file path depending on your store version. While that really shouldn't be an issue, it is a change.

We plan on maintaining the current functionality for existing store versions and for the near future, but we may eventually force all foxycart_includes.js and related CSS files to use the CDN. This should be a benefit to everybody, but we wanted to bring this up with the community to get feedback. If anybody has questions or concerns please let us know so we can address them and ensure things are communicated clearly.

I think that's a really good move. When I upgrade my store versions, I have to test it out anyway, and a small link change is not a large deal. If it makes foxycart faster, I think it's a big win (esp. for folks in other countries).

I completely agree. To scale according to your growth, a CDN sounds like a reasonable solution--one that larger scale sites likely already leverage (or should be).

IMO, I would much rather see responsiveness and add a little work to my development cycle for new/upgraded stores (as Chuck pointed out), than to trust that I am being served the correctly version JS/CSS. Depending on your template structure, it can be as simple as updating a single source reference to take into account the new version, which isn't much to ask at all.

I have yet to see a client accidentally "upgrade their store" on their own, but this may also serve as a fail-safe, as well. Should a client attempt to upgrade their store, having the older JS/CSS references in place could potentially result in unwanted/erroneous behavior prompting a call to their developer to "look into it".

Bottom line: Do whatever you need to support your growth. Your customers will be more satisfied with FC as a service, and your developers are already satisfied enough because they're getting to leverage FoxyCart

Update on this front:
After a LONG time testing different CDNs, and a false start with one, it looks like we've got one that works really well. We'll keep everybody posted once we have some URLs to use. Response times I'm seeing in Los Angeles for the foxycart.js file are between 12-20ms, which is pretty awesome (compared to ~82ms on our primary app server from my location). Tests from Russia and Australia seem to be improving by about 100ms. Obviously, your mileage will vary depending on location, but it looks to be an improvement, and will allow us to grow with one less thing to worry about.

Update, since we might as well: The code's been committed to our dev branch but needs some reviewing before we push it out. Since it's purely an additive type of thing we do currently plan on adding it to v060, but depending on when we're able to get to things that might change. But we'll update on this thread once it does go live.

Please try it out and let us know if you have any issues with anything. The CDN in 060 is really more of a test just to make sure it's working well for us and for you, so if you see anything strange just let us know.

Yeah, way back when... oh, great, not "way back when", but right now...

So anyway, the "sample code" in the admin has https URLs for all the include files. In probably 99% of use cases, that's doing nothing but adding more overhead to the requests and slowing things down. I'd thought that we changed that but I was wrong. At least, we didn't change it in the admin.

So: What are the implications?
If you need to load those files from a page being served as https, you'll have to use the old URLs. That's basically it.

We do plan on extending the CDN to serve more assets, including cached images on the cart and checkout, so we will likely eventually have the CDN support SSL, but that's a little bit off at this point.

So... Assuming that I'm deploying FoxyCart on a regular CMS w/o SSL, there shouldn't be any ill effect of switching to the CDN at this point. Got it.

It seems to me that it would be a good idea to add two images to the CDN at this point (since they're called from the /themes/standard/theme.foxybox.css file, and the extra requests are likely taxing your servers at least as much as the css):

Yeah, we'll definitely be adding those. Why it's like that is kind of related to way way back when, but the www site is on an entirely different server than the admin and app services, and that server (the www one) is fine. But yes, those will be moving in our next release.

I love that so many of our users are so on the ball with these things. It makes our lives a lot easier.

@oskay, yeah, looks like Vanilla is getting hit by bot spam. We're halfway through a move to Vanilla2 (which is actually quite nice), but until then I think we'll just deal with it manually unless it gets too crazy.

Nice! I didn't know about this, will give it a shot asap as it is a little uncomfortably slow here in Australia.

I would also add that it doesn't concern me to link to a specific version's resources on the site.. but if you guys could update the files on the CDN on a per store basis, then that would be even better and the path then doesn't need to change on the website again.. requiring just a change to use the CDN (existing sites) but after that it is fixed.

Edit: Oh I should RTFM first.. looks like that's what you have done. :-D

Edit: Oh I should RTFM first.. looks like that's what you have done. :-D

Haha, yeah, I'm actually pretty happy with how we were able to make the CDN behave. ... REALLY happy, actually. Our next release should see more of the files (images and such) moved to the CDN as well. Let us know how it works out for you in Australia. We're hearing that it at least halves the response times.