ASGI middleware for static file serving with content-based cache busting
Project description
Staticware
ASGI middleware for static file serving with content-based cache busting. Zero runtime dependencies.
- Created by Audrey M. Roy Greenfeld
- PyPI package: https://pypi.org/project/staticware/
- Free software: MIT License
Features
- Serves static files over ASGI with content-hashed filenames for cache busting
- Hashed filenames get
Cache-Control: public, max-age=31536000, immutable - Original filenames still work, without aggressive caching
StaticRewriteMiddlewareautomatically rewrites static paths in HTML responsesstatic.url()resolves cache-busted URLs for use in templates- Works with any ASGI framework: Starlette, FastAPI, Air, Litestar, Django, or raw ASGI
- Zero runtime dependencies
Quick Start
from staticware import HashedStatic, StaticRewriteMiddleware
# Point at your static files directory
static = HashedStatic("static")
# Mount it however your framework mounts sub-apps:
app.mount("/static", static)
# Wrap any ASGI app to rewrite static paths in HTML responses
app = StaticRewriteMiddleware(app, static=static)
# In templates, resolve cache-busted URLs:
static.url("styles.css") # /static/styles.a1b2c3d4.css
static.url("images/logo.png") # /static/images/logo.7e4f9a01.png
Documentation
Documentation is built with Zensical and deployed to GitHub Pages.
- Live site: https://feldroy.github.io/staticware/
- Preview locally:
just docs-serve(serves at http://localhost:8000) - Build:
just docs-build
API documentation is auto-generated from docstrings using mkdocstrings.
Docs deploy automatically on push to main via GitHub Actions. To enable this, go to your repo's Settings > Pages and set the source to GitHub Actions.
Development
To set up for local development:
git clone git@github.com:feldroy/staticware.git
cd staticware
uv sync
Run tests:
uv run pytest
Run quality checks (format, lint, type check, test):
just qa
Author
Staticware was created in 2026 by Audrey M. Roy Greenfeld.
Built with Cookiecutter and the audreyfeldroy/cookiecutter-pypackage project template.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file staticware-0.2.0.tar.gz.
File metadata
- Download URL: staticware-0.2.0.tar.gz
- Upload date:
- Size: 53.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
991c4d0c74a5173b5f058b8e7e81314a569f95d8497a3120811d62fc30629838
|
|
| MD5 |
8075908df4806578af957bd3f829b78b
|
|
| BLAKE2b-256 |
9a47f3effaeff071e7d87b64ded37073e1728fbdc432bc166b689ba442050fb2
|
Provenance
The following attestation bundles were made for staticware-0.2.0.tar.gz:
Publisher:
publish.yml on feldroy/staticware
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
staticware-0.2.0.tar.gz -
Subject digest:
991c4d0c74a5173b5f058b8e7e81314a569f95d8497a3120811d62fc30629838 - Sigstore transparency entry: 1096682131
- Sigstore integration time:
-
Permalink:
feldroy/staticware@70c80f2ab6d03b803586f05a41f5215572f6d3e2 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/feldroy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@70c80f2ab6d03b803586f05a41f5215572f6d3e2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file staticware-0.2.0-py3-none-any.whl.
File metadata
- Download URL: staticware-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
679c612a30eb50a7c77b07978acebf34496f4a41921a1b49ab8d98473f1f1069
|
|
| MD5 |
ebf51922fa7deb3963c854113449afff
|
|
| BLAKE2b-256 |
378969c791f2bb2b5fa6d7bf8e2fd236e6a10490b06dacfd8e4e9f48d8a8ae0a
|
Provenance
The following attestation bundles were made for staticware-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on feldroy/staticware
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
staticware-0.2.0-py3-none-any.whl -
Subject digest:
679c612a30eb50a7c77b07978acebf34496f4a41921a1b49ab8d98473f1f1069 - Sigstore transparency entry: 1096682135
- Sigstore integration time:
-
Permalink:
feldroy/staticware@70c80f2ab6d03b803586f05a41f5215572f6d3e2 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/feldroy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@70c80f2ab6d03b803586f05a41f5215572f6d3e2 -
Trigger Event:
push
-
Statement type: