mirror of
https://github.com/simonw/datasette.git
synced 2026-09-29 05:14:21 +02:00
Add cache-busted static asset helper (#2804)
* Add cache-busted static asset helper Add a static() helper for Datasette, plugin, and mounted static assets that appends content-based hashes, caches hashes in production, and serves matching hashed asset URLs with immutable far-future cache headers. Closes #2800
This commit is contained in:
parent
a4f74d1d2b
commit
5eca46a4bc
25 changed files with 361 additions and 65 deletions
|
|
@ -11,6 +11,7 @@ from datasette.utils.sqlite import (
|
|||
sqlite_table_type,
|
||||
supports_returning,
|
||||
)
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
|
|
@ -835,6 +836,12 @@ def test_pairs_to_nested_config(pairs, expected):
|
|||
assert actual == expected
|
||||
|
||||
|
||||
def test_sha256_file(tmp_path):
|
||||
path = tmp_path / "test.txt"
|
||||
path.write_text("hello")
|
||||
assert utils.sha256_file(path, chunk_size=2) == hashlib.sha256(b"hello").hexdigest()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_calculate_etag(tmp_path):
|
||||
path = tmp_path / "test.txt"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue