Skip to main content

ASGI middleware for static file serving with content-based cache busting

Project description

Staticware

PyPI version

ASGI middleware for static file serving with content-based cache busting. Zero runtime dependencies.

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
  • StaticRewriteMiddleware automatically rewrites static paths in HTML responses
  • static.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.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

staticware-0.2.0.tar.gz (53.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

staticware-0.2.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

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

Hashes for staticware-0.2.0.tar.gz
Algorithm Hash digest
SHA256 991c4d0c74a5173b5f058b8e7e81314a569f95d8497a3120811d62fc30629838
MD5 8075908df4806578af957bd3f829b78b
BLAKE2b-256 9a47f3effaeff071e7d87b64ded37073e1728fbdc432bc166b689ba442050fb2

See more details on using hashes here.

Provenance

The following attestation bundles were made for staticware-0.2.0.tar.gz:

Publisher: publish.yml on feldroy/staticware

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for staticware-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 679c612a30eb50a7c77b07978acebf34496f4a41921a1b49ab8d98473f1f1069
MD5 ebf51922fa7deb3963c854113449afff
BLAKE2b-256 378969c791f2bb2b5fa6d7bf8e2fd236e6a10490b06dacfd8e4e9f48d8a8ae0a

See more details on using hashes here.

Provenance

The following attestation bundles were made for staticware-0.2.0-py3-none-any.whl:

Publisher: publish.yml on feldroy/staticware

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page