Skip to content

Commit 750c1f6

Browse files
committed
Show the complete setup sequence in Quick Start and usage docs
The examples previously jumped from creating a StaticFiles instance to wrapping the app with middleware, skipping the mount call that connects them. Both README and usage docs now show all three pieces: create, mount, wrap. The usage docs also explain that file hashes are computed once at startup, so readers know to restart the ASGI process after deploying new static files.
1 parent 591434e commit 750c1f6

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ from staticware import StaticFiles, StaticRewriteMiddleware
2828
# Point at your static files directory
2929
static = StaticFiles("static")
3030

31+
# Mount it however your framework mounts sub-apps:
32+
app.mount("/static", static)
33+
3134
# Wrap any ASGI app to rewrite static paths in HTML responses
32-
app = StaticRewriteMiddleware(your_app, static=static)
35+
app = StaticRewriteMiddleware(app, static=static)
3336

3437
# In templates, resolve cache-busted URLs:
3538
static.url("styles.css") # /static/styles.a1b2c3d4.css

docs/usage.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,18 @@ Create a `StaticFiles` instance pointing at your static files directory, then wr
88
from staticware import StaticFiles, StaticRewriteMiddleware
99

1010
static = StaticFiles("static")
11-
app = StaticRewriteMiddleware(your_app, static=static)
11+
12+
# Mount it however your framework mounts sub-apps:
13+
app.mount("/static", static)
14+
15+
# Wrap the app to rewrite static paths in HTML responses:
16+
app = StaticRewriteMiddleware(app, static=static)
1217
```
1318

1419
`StaticFiles` hashes every file in the directory at startup. When a browser requests the hashed filename, it gets an immutable cache header. When it requests the original filename, the file is served without aggressive caching.
1520

21+
File hashes are computed once when `StaticFiles` is created. If you deploy updated static files, restart the ASGI process to pick up the new hashes. This is the same model used by Starlette and most ASGI static file handlers.
22+
1623
## Resolving URLs in Templates
1724

1825
Use `static.url()` to get the cache-busted URL for a file:

0 commit comments

Comments
 (0)