feat(perf): enable GZipMiddleware reducing static transfer size by 81.7%
This commit is contained in:
1 parent
1ee39d66bd
commit
25576de87a
3 files changed
+29
-3
No files matched your search
@@ -788,5 +788,26 @@ def test_srs_queue_and_quiz_tag_filtering():
|
||||
assert not any(q["card"]["id"] == c2["id"] for q in quiz_items)
|
||||
|
||||
|
||||
def test_gzip_compression():
|
||||
# 1. Assets >= 1000 bytes receive GZip encoding when requested
|
||||
resp_js = client.get("/static/js/app.js", headers={"Accept-Encoding": "gzip"})
|
||||
assert resp_js.status_code == 200
|
||||
assert resp_js.headers.get("content-encoding") == "gzip"
|
||||
|
||||
resp_css = client.get("/static/css/style.css", headers={"Accept-Encoding": "gzip"})
|
||||
assert resp_css.status_code == 200
|
||||
assert resp_css.headers.get("content-encoding") == "gzip"
|
||||
|
||||
resp_html = client.get("/", headers={"Accept-Encoding": "gzip"})
|
||||
assert resp_html.status_code == 200
|
||||
assert resp_html.headers.get("content-encoding") == "gzip"
|
||||
|
||||
# 2. Assets < 1000 bytes are not compressed (respecting minimum_size=1000)
|
||||
resp_manifest = client.get("/manifest.json", headers={"Accept-Encoding": "gzip"})
|
||||
assert resp_manifest.status_code == 200
|
||||
assert resp_manifest.headers.get("content-encoding") is None
|
||||
|
||||
# 3. Requests without gzip Accept-Encoding do not receive gzip
|
||||
resp_raw = client.get("/static/js/app.js", headers={"Accept-Encoding": "identity"})
|
||||
assert resp_raw.status_code == 200
|
||||
assert resp_raw.headers.get("content-encoding") is None
|
||||
Reference in new issue
Block a user