diff options
| author | Xe Iaso <me@xeiaso.net> | 2023-02-23 16:20:57 -0500 |
|---|---|---|
| committer | Xe Iaso <me@xeiaso.net> | 2023-02-23 16:20:57 -0500 |
| commit | 9afc37eaed75ad4cf60302be8494303bb4db3fcc (patch) | |
| tree | 3dbd6a596d6f4f457e32cefaf7e6974e4e662bf6 /cmd | |
| parent | 5be5a8fd26bf2318201652872a42e68618f87510 (diff) | |
| download | x-9afc37eaed75ad4cf60302be8494303bb4db3fcc.tar.xz x-9afc37eaed75ad4cf60302be8494303bb4db3fcc.zip | |
bring back portable services
Signed-off-by: Xe Iaso <me@xeiaso.net>
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/xedn/build.go | 2 | ||||
| -rw-r--r-- | cmd/xedn/doc/README.md | 28 | ||||
| -rw-r--r-- | cmd/xedn/main.go | 4 |
3 files changed, 31 insertions, 3 deletions
diff --git a/cmd/xedn/build.go b/cmd/xedn/build.go index ded63d7..11aea9b 100644 --- a/cmd/xedn/build.go +++ b/cmd/xedn/build.go @@ -18,7 +18,7 @@ func main() { defer cancel() env := append(os.Environ(), []string{"CGO_ENABLED=0", "GOOS=linux"}...) - yeet.ShouldWork(ctx, env, yeet.WD, "nix", "build", ".#xedn-docker") + yeet.ShouldWork(ctx, env, yeet.WD, "nix", "build", ".#docker.xedn") yeet.DockerLoadResult(ctx, "./result") yeet.DockerPush(ctx, "registry.fly.io/xedn:latest") yeet.ShouldWork(ctx, env, yeet.WD, "flyctl", "deploy", "--now") diff --git a/cmd/xedn/doc/README.md b/cmd/xedn/doc/README.md new file mode 100644 index 0000000..0524702 --- /dev/null +++ b/cmd/xedn/doc/README.md @@ -0,0 +1,28 @@ +# XeDN + +Xe's CDN replacement service + +## Goal + +XeDN is a CDN replacement service. It is a tool that enables you to +serve files from a central storage pool (such as Backblaze B2) in a +way that caches all those files locally. This lets you put several +instances of XeDN in different datacentres globally and then each +instance will act as a local cache. This strategy lets you decrease +observable latency for users. + +The goal of this service is to replace Cloudflare for my own uses. + +## Design + +At a high level, XeDN is a caching HTTP proxy. It caches files locally +using [BoltDB](https://github.com/etcd-io/bbolt) and serves from that +cache whenever possible. XeDN pulls files from its source (currently +over HTTP, but this can be changed in the future) and aggressively +caches them in the database. When each file is cached, it has a +default lifetime of one week. This lifetime is extended every time a +file is requested, hopefully making sure that each file that is +commonly used is never requested from backend servers. This does make +genuinely updating content hard, so users of XeDN are encouraged to +assume that the backend is an _append-only_ store. + diff --git a/cmd/xedn/main.go b/cmd/xedn/main.go index 377c904..7044060 100644 --- a/cmd/xedn/main.go +++ b/cmd/xedn/main.go @@ -130,14 +130,14 @@ func (dc *Cache) Save(dir string, resp *http.Response) error { return err } - diesAt := time.Now().Add(604800 * time.Second).Format(http.TimeFormat) + diesAt := time.Now().AddDate(0, 0, 7).Format(http.TimeFormat) if err := bkt.Put([]byte("diesAt"), []byte(diesAt)); err != nil { return err } // cache control headers - resp.Header.Set("Cache-Control", "max-age:604800") + resp.Header.Set("Cache-Control", "max-age:604800") // one week resp.Header.Set("Expires", diesAt) return nil |
