Can Github be CDN for Salesforce Projects ?

by - 2:10 AM

Salesforce Static Resources

Salesforce have came a long way through but, I still find there are areas in the world of platform where massive facelift needs to be done and one of the most challenging corner is the 'static resources' in Salesforce. Every-time, you have to upload your static files (like say javascript/css and other files) to Salesforce even for making a minor change. I always felt a need of private CDN (Content Delivery Network) option from Salesforce and I hope Salesforce will focus a better solution to make steps easy for developers, so that they avoid repetitive job of uploading code.

Hunt for CDN to share resources

Clearly we know, Salesforce static resources are secure as they are shielded by Platform security channel, but if we deal with some shared resource which are common and shared by multiple applications, in this case, I always look nothing better than Github Itself, as pushing my code to is painless.

Can Github be my CDN ?

Unfortunately, you cannot deliver files in your application directly from Github (supported by Content-Type) but there is solution to the problem. Use RawGit to access your Github resources.
Have you ever wanted to access Github file resource directly as static hosted files but weren't able to ? Well RawGit give you a way to take the URL reference for any Github resources and make it properly accessible by web browser or client application. RawGit offer both url for you, to be consumed for production and sandbox, you can generate both the endpoints. It provides a proxy that maps the HTTP (Content-Type) in the header to file type, so that it can be loaded properly.

Since RawGit can generate both sandbox and production url endpoints for them, but make sure you understand the difference in them and this service is CORS enabled at the same time.

Creating CDN files from Github is simple and three steps process

  • filter_dramaStep 1: Grab your GitHub Public Repo URL
  • place Step 2: Go to Rawgit and paste the url

  • whatshot Step 3: Import generated url in your application

Start using CDN in your Salesforce Projects Easily

You May Also Like