skillfed

servestatic

Production-grade static file server for Python WSGI & ASGI.

servestatic v4.3.1 179.4K downloads/30d#10,172 on PyPI98
Permissive license MIT Active released

What it is and what it does

ServeStatic is a static file server middleware for Python web applications that handles compression, cache headers, and CDN integration automatically. It works as a drop-in middleware for ASGI and WSGI apps, or as a standalone server, and is designed to simplify deployments on platforms like Heroku and OpenShift where external services are unavailable or undesirable.

The package pre-computes file metadata and headers at initialization, then serves requests with minimal overhead. It automatically handles Accept-Encoding negotiation, sets far-future cache headers for immutable files, and integrates with CDNs to ensure the vast majority of traffic bypasses your application entirely. A CLI provides utilities for multi-format compression, filename hashing, and manifest generation. Django users get extra auto-configuration features.

Use it for:

  • Deploy a Django or FastAPI app to Heroku or OpenShift without managing a separate Nginx instance.
  • Serve static assets behind a CDN with automatic cache-busting via filename hashing.
  • Eliminate S3 push-based deployment complexity by serving static files directly from your app with CDN caching.
  • Automatically compress and serve gzip or brotli variants of CSS and JavaScript based on client Accept-Encoding.
  • Run a self-contained production app that handles both dynamic content and static files without external dependencies.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

ServeStatic serves static files efficiently from Python ASGI/WSGI applications with automatic compression, cache headers, and CDN integration, eliminating the need for separate web servers or external storage services.

Yes. ServeStatic is production-stable, actively maintained, has no known vulnerabilities, and solves a real deployment problem—especially on PaaS platforms. The single lightweight dependency and low install friction make it a practical choice. Use it if you need static file serving without external infrastructure; skip it if you already have Nginx or S3 in your stack.

Install

servestatic on PyPI

pip

pip install servestatic

uv

uv add servestatic

poetry

poetry add servestatic

Installing servestatic

Before you install

Low friction: single pure-Python dependency (asgiref), wheel-only distribution, and active maintenance with a recent release 68 days ago. Supports Python 3.10 through 3.14.

License in practice

MIT license (permissive) allows free use, modification, and distribution in commercial and private projects with minimal restrictions.

Quickstart

pip install servestatic

from servestatic import ServeStaticMiddleware

app = ServeStaticMiddleware(app, root='staticfiles')

Requires Python 3.10 or later; asgiref must be installed as a runtime dependency.

Verify before relying

  • Whether the package's performance claims (dictionary lookup, sendfile syscall) are verified under real-world load.
  • Specific CDN providers tested or recommended for optimal caching behavior.
  • Whether Django auto-configuration features are documented with examples.
  • Compression format support (gzip, brotli, zstd) and their default enablement.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 1 — asgiref
Maintenance actively maintained — 68 days since the last release
Last repo commit
First released
Downloads 179,423/month — #10,172 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: servestatic-4.3.1-py3-none-any.whl

Keywords: asgi, django, http, server, static, staticfiles, wsgi

Development Status :: 5 - Production/StableFramework :: DjangoIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Communications :: File SharingTopic :: Internet :: WWW/HTTPTopic :: Internet :: WWW/HTTP :: WSGI :: Middleware

Tags

static file serving pythonasgi wsgi static filescdn-friendly file servingpython static middlewareheroku static filescompressed static assetscache headers automation
static-filesmiddlewarepaas-deployment

More WWW/HTTP packages