Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

IWC: Interval Web Cache

IWC is a lightweight, zero-dependency Python utility designed to mirror and cache any URL or API endpoint. It runs a background worker to fetch data at a set interval, stores it in memory and on disk, and serves it via a built-in high-performance web server.

It is perfect for bypassing rate limits, providing offline redundancy for critical configurations, or mirroring subscription links in restricted network environments.

🚀 Key Features

  • Zero Dependencies: Uses only the Python Standard Library (http.server, urllib). No pip install required.
  • Background Refresh: Automatically updates the cache in a separate thread without blocking requests.
  • Disk Persistence: Saves the last successful fetch to a local file. If the server restarts or the source is down, IWC serves the last known good data.
  • Rate Limit Protection: Act as a middleman to protect your source API from being overwhelmed by too many clients.
  • Health Monitoring: Includes a /status endpoint to verify the cache state and uptime.
  • Network Ready: Configured to bind to 0.0.0.0 to allow access across your local network or VPS.

🛠️ Installation & Setup

Since IWC uses pure Python, setup is as simple as downloading the script.

  1. Download the script:

    curl -O https://raw.githubusercontent.com/your-username/IWC/main/iwc.py
  2. Configure your settings: Open iwc.py and edit the configuration block at the top:

    SOURCE_URL = "https://api.example.com/data.json" 
    UPDATE_INTERVAL = 300  # Seconds (5 minutes)
    PORT = 5000            # Port to serve on
  3. Run the server:

    python3 iwc.py

📖 Usage

Once running, the server provides two primary endpoints:

Endpoint Description
GET / Returns the raw cached content from the source URL.
GET /status Returns a JSON object showing if the cache is active and healthy.

Example Use Cases

  • API Mirroring: Cache a public API (like weather or crypto prices) to avoid hitting usage quotas.
  • Config Distribution: Host a central configuration file that multiple devices need to read frequently.
  • Subscription Mirror: Re-host subscription links or manifest files that are frequently updated but occasionally unreachable.

🛡️ Reliability

IWC is built with a "Serve-at-all-costs" philosophy:

  1. Memory First: Serves data instantly from RAM.
  2. Disk Backup: If RAM is empty on boot, it checks the local .dat file.
  3. Graceful Failure: If the source URL goes down, IWC continues serving the last successful fetch until the source returns online.

Basically: "No-install, zero-dependency caching proxy."

About

Cache HTTP Responses

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages