Go Casper

Cache aware server push (CASPer) in Golang
Alternatives To Go Casper
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Frp68,10192 days ago78July 10, 202297apache-2.0Go
A fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet.
Caddy47,60111833419 hours ago85October 26, 202080apache-2.0Go
Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Vapor22,858
6 days agoNovember 16, 2021113mitSwift
💧 A server-side Swift HTTP web framework.
Postgrest20,617
43 days ago37July 12, 2022207mitHaskell
REST API for any Postgres database
Aiohttp13,6027,3554,894a day ago220November 14, 2021497otherPython
Asynchronous HTTP client/server framework for asyncio and Python
Node Http Proxy13,363398,0652,932a day ago103May 17, 2020579otherJavaScript
A full-featured http proxy for node.js
Http Server12,68846,3037,9322 months ago49May 31, 2022135mitJavaScript
a simple zero-configuration command-line http server
Chisel9,1602214 days ago27February 03, 2022184mitGo
A fast TCP/UDP tunnel over HTTP
Warp8,137733553 days ago34November 09, 2021218mitRust
A super-easy, composable, web server framework for warp speeds.
Proxygen7,826
7 hours ago40otherC++
A collection of C++ HTTP libraries including an easy to use HTTP server.
Alternatives To Go Casper
Select To Compare


Alternative Project Comparisons
Readme

go-casper Go Documentation Travis MIT License

Package go-casper is Golang implementation of H2O's CASPer (cache-aware server-push).

Go 1.8 is going to support HTTP/2 server push. Server push allows us to send resources like CSS or JavaScript files before the client asks (so we can expect faster page rendering). As described on this post or this issue, one of the important things to use server push is to know when to push. Since it's waste of the network bandwidth (and cause negative effects on response time), you should avoid to push the asset which has already been cached by the client.

To solve these problem, H2O, a server that provides full advantage of HTTP/2 features, introduces CASPer. CASPer maintains a fingerprint of the browser caches (Golomb-compressed bloom filter) as a cookie, and cancels server-push if the fingerprint indicates the client is known to be in possession of the contents.

go-casper implements H2O's CASPer and provides similar fucntinality in any golang http server. It wraps go's standard server push method (see "HTTP/2 Server Push · Go, the unwritten parts" if you don't how to use it) and maintains a fingerprint of browser caches and decides to push or cancel. The fingerprint is generated by using golomb-coded sets (a compressed encoding of Bloom filter).

The full documentation is available on Godoc.

NOTE1: This project is still a proof of concept and still under heavy implementation. API may be changed in future and documentaion is incomplete. This code should not be run in production. Comments are all welcome!

NOTE2: There is a draft by H2O author which defines a HTTP/2 frame type to allow clients to inform the server of their cache's contents 👏 This pacakage can be replace with it in future.

Example

Below is a simple example of usage.

// Initialize casper with false-positive probability 
// 1/64 and number of assets 10.
pusher := casper.New(1<<6, 10)

http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {    
    
    // Execute cache aware server push. 
    // 
    // In this example, it generates a fingerprint "JA" and set it
    // as "x-go-casper" cookie value.
    // 
    // If you access this handler first time, it runs server-push.
    // But from next time, with same client, it cancels pushing since 
    // cookie indicates asset has already been cached by the client.
    if _, err := pusher.Push(w, r, []string{"/static/example.js"}, nil); err != nil {
        log.Printf("[ERROR] Failed to push assets: %s", err)
    }

    // ...
})

You can find the complete example here.

Popular Server Projects
Popular Http Projects
Popular Networking Categories

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Go
Golang
Server
Http
Fingerprint
Bloom Filter
H2o