Skip to content

Latest commit

 

History

History
49 lines (36 loc) · 1.37 KB

File metadata and controls

49 lines (36 loc) · 1.37 KB

SimpleConfigCacheCDN

A very minimal CDN-style cache service implementation for holding config files (small UTF-8 plain text).

Originally designed for serving a copy of Squad game servers' remote admin/ban configs.

Always try origin first, and serve latest cached version in case origin is unreachable (as fallback).

Requirements

  • Python 3.11+
pip install flask requests

Using a venv is recommended.

Config

Within the top section of main.py

Test run:

python main.py
# GET http://localhost:56564/file/app_cfg

Note

There's 2 prepended comment lines added for noticing origin server status and time:

// Synced {last_check_time} or // Origin Unreachable {last_check_time}, using last cached version
// Cached version fetched at {fetched_at}

You can change the prefix (like // -> #) by changing HEADER_PREFIX in config.

To remove them entirely, you need to modify _prepend_comment() by yourself.

Serving with Waitress (recommended for production)

pip install flask requests waitress Paste
# Run
waitress-serve --host=0.0.0.0 --port=<port> main:app

Endpoints

  • GET /file/<key> -> return cached config file (try origin, fallback to cache if failed).
  • GET /health -> returns ok for api monitoring.

License

This project is licensed under the GNU Affero General Public License v3.0.