github.com/go-on/cdncache
go get github.com/go-on/cdncache

github.com/go-on/cdncache

a cache for CDN files

by go-on

v1.2.1 (see all)License:MIT
go get github.com/go-on/cdncache
Readme

cdncache

GoDoc

a cache for CDN files

Example

package main

import (
    "fmt"
    "gopkg.in/go-on/cdncache.v1"
    "net/http"
)

// mounts the cached files at /cdn-cache/
var cdn1 = cdncache.CDN("/cdn-cache/")

// does no caching (empty mountpoint)
var cdn2 = cdncache.CDN("")

func serve(w http.ResponseWriter, r *http.Request) {
    fmt.Fprintf(w,
        `<html>
        <body>
        <a href="%s">local (cached)</a><br>
        <a href="%s">remote (CDN)</a><br>
        </body>
        </html>`,
        cdn1("//code.jquery.com/jquery-1.11.0.min.js"),
        cdn2("//code.jquery.com/jquery-1.11.0.min.js"),
    )
}

func main() {
    http.Handle("/", http.HandlerFunc(serve))
    http.ListenAndServe(":8383", nil)
}

GitHub Stars

12

LAST COMMIT

7yrs ago

MAINTAINERS

0

CONTRIBUTORS

2

OPEN ISSUES

0

OPEN PRs

0
VersionTagPublished
v0.0.0-20141215123906-fc3aa2f9f549
10mos ago
v1.2.1
3yrs ago
No alternatives found
No tutorials found
Add a tutorial