Category Archives: CDN

Sortable, searchable table with pagination using knockout.js in Salesforce

This is a demo using knockout.js to create a table for listing records of any object custom, standard or combinations of data from multiple objects.  The table is sortable and searchable using a typeahead search field.  It also includes a dropdown to limit the number of records visible as well as pagination.

This is what it looks like in its most basic styling:

This is the link to the working demo

 

This is the component that holds the knockout code:

This is the controller to retrieve the records using a remote action:

The visualforce page:

 

Hosted JQuery and Bootstrap Libraries

Decreased Latency

A CDN distributes your static content across servers in various, diverse physical locations. When a user’s browser resolves the URL for these files, their download will automatically target the closest available server in the network.

In the case of Google’s AJAX Libraries CDN, what this means is that any users not physically near your server will be able to download jQuery faster than if you force them to download it from your arbitrarily located server. There are a handful of CDN services comparable to Google’s, but it’s hard to beat the price of free! This benefit alone could decide the issue, but there’s even more.

Increased parallelism

To avoid needlessly overloading servers, browsers limit the number of connections that can be made simultaneously. Depending on which browser, this limit may be as low as two connections per hostname. Using the Google AJAX Libraries CDN eliminates one request to your site, allowing more of your local content to downloaded in parallel. It doesn’t make a gigantic difference for users with a six concurrent connection browser, but for those still running a browser that only allows two, the difference is noticeable.

Better caching

Potentially the greatest benefit of using the Google AJAX Libraries CDN is that your users may not need to download jQuery at all. No matter how well optimized your site is, if you’re hosting jQuery locally then your users must download it at least once. Each of your users probably already has dozens of identical copies of jQuery in their browser’s cache, but those copies of jQuery are ignored when they visit your site.

However, when a browser sees references to CDN-hosted copies of jQuery, it understands that all of those references do refer to the exact same file. With all of these CDN references point to exactly the same URLs, the browser can trust that those files truly are identical and won’t waste time re-requesting the file if it’s already cached. Thus, the browser is able to use a single copy that’s cached on-disk, regardless of which site the CDN references appear on.

This creates a potent “cross-site caching” effect which all sites using the CDN benefit from. Since Google’s CDN serves the file with headers that attempt to cache the file for up to one year, this effect truly has amazing potential. With many thousands of the most trafficked sites on the Internet already using the Google CDN to serve jQuery, it’s quite possible that many of your users will never make a single HTTP request for jQuery when they visit sites using the CDN. Even if someone visits hundreds of sites using the same Google hosted version of jQuery, they will only need download it once!

Links to JQuery Libraries: https://developers.google.com/speed/libraries/devguide#jquery

Links to Bootstrap Libraries:  http://www.bootstrapcdn.com/