Git Product home page Git Product logo

cdn.cocoapods.org's Introduction

The new CDN, powered by GitHub Actions

Following the increasing cost and several outages on the Netlify service, it was decided to look for simpler alternatives.

The new build process uses GH Actions to create the static indices and runs roughly every 7 minutes. The result is deployed into a GitHub Pages environment.

How the CDN works

Our CDN works by taking the CocoaPods Specs repo and creating static files which tells the CocoaPods CLI what pods and versions exist currently.

The CocoaPods CLI will use the information from files like:

https://cdn.cocoapods.org/all_pods.txt:

!ProtoCompiler
!ProtoCompiler-gRPCPlugin
+verify
-
0001
10Clock
120301
1210
1229Sdk
12306DeveCocoa
180305Pod
19WhereSVProgressHUD
1BAIDUSDKSYDemo
1PasswordExtension
1PasswordExtensionHaha
20170610test
20180408Test
...

There are a set of known prefixes for all Podspec paths, you take the name of the pod, create a SHA (using md5) of it and take the first three characters.

E,g, for the Podspec name:AppNetworkManager -> 222d4d61b20ded1118cedbb42c07ce5f. So, it lives at 2/2/2.

the CocoaPods CLI can get a list of versions for all pods which live at 2/2/2 from these know indices:

https://cdn.cocoapods.org/all_pods_versions_2_2_2.txt:

AppNetworkManager/1.0.0/1.0.1/1.0.2/1.0.4/1.0.5/1.0.6/1.0.7
BIZGrid4plus1CollectionViewLayout/1.0.0
ContactsWrapper/0.0.1/0.0.2/0.0.3/0.9/1.0/1.0.1/1.0.2
DfPodTest/0.0.1/0.0.2
GoogleConversionTracking/1.2.0/2.1.0/3.0.0/3.1.1/3.2.0/3.3.0/3.3.1/3.4.0
HZTabbar/0.0.1/0.0.2/0.0.3/0.0.4
IAPHelperLV/0.1.0/0.1.1/0.1.2
IDLib/0.2.0/0.3.0
...

Which means to get a podspec JSON, to ensure the CLI can resolve all your dependencies, then the CLI will make HTTP requests like these:

  • https://cdn.cocoapods.org/Specs/2/2/2/AppNetworkManager/1.0.0/AppNetworkManager.podspec.json
  • https://cdn.cocoapods.org/Specs/2/2/2/ContactsWrapper/0.9/ContactsWrapper.podspec.json
  • https://cdn.cocoapods.org/Specs/2/2/2/IDLib/0.2.0/IDLib.podspec.json

Repeat this process for all the dependencies of your dependencies, and that is enough to be able to download just the Podspecs specs needed for your whole dependency tree. Meaning you don't need to do the full clone of the Specs repo.

How the CDN is implemented

This repo is responsible for generating all_pods.txt and the sharded indices. That happens in Scripts/create_pods_and_versions_index.rb.

These files get pushed to the GitHub Pages branch of this repo.

We then use CloudFlare CDN to redirect incoming URLs either to this repo's GitHub Pages static site, or to a jsDelivr backed copy of the CocoaPods Specs repo based on this re-direct rule:

cdn.cocoapods.org/Specs/* ->
https://cdn.jsdelivr.net/cocoa/Specs/$1

This repo does not contain any redirect code as it's not possible to do so in GitHub Pages.

cdn.cocoapods.org's People

Contributors

igor-makarov avatar orta avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.