Give the addresses an address version of their own, raised to a1
Every season poster changed with the joined picks, but the Kometa file kept handing out
?v=r3, an address clients keep for good: they would never load the new season posters. Raising
the render version instead would draw every kept layer and finished picture again, though only
the season posters changed.
poster_options.ADDRESS_VERSION ("a1") sits beside RENDER_VERSION: the Kometa file writes it into
every poster address, and only an address carrying it is sent the immutable Cache-Control; an
address with ?v=r3 is now any other address (a day, then its ETag). Layers and finished pictures
stay keyed by RENDER_VERSION, still r3, so nothing kept is drawn again except the season posters
whose photo changed. The API's option text, the Kometa docstring and the README say "address
version".
The options test: ?v=a1 is kept for good, ?v=r3 no longer (on master it fails: no
ADDRESS_VERSION, and ?v=r3 is still the immutable address).
Builds: docs/posters.md at f6b9f937d0 (Finished images: what clients keep, the address version)
Claude-Session: https://claude.ai/code/session_01JG73KFhbaNj3tyJ8tKmE3W
This commit is contained in:
+7
-4
@@ -8,9 +8,12 @@ import re
|
||||
from dataclasses import dataclass
|
||||
from typing import Iterable, Optional
|
||||
|
||||
# Part of every layer's and every finished picture's key: raised when what a picture looks like changes, so no
|
||||
# Part of every layer's and every finished picture's key: raised only when the drawing itself changes, so no
|
||||
# picture made before is served again. r3: licensed sources, kept layers, options and credits.
|
||||
RENDER_VERSION = "r3"
|
||||
# Carried by the address clients are given (?v=), separate from RENDER_VERSION: raised when a look changes, so clients
|
||||
# load the address again, served from the pictures already kept. a1: every season poster changed (the season photos).
|
||||
ADDRESS_VERSION = "a1"
|
||||
|
||||
# A frame is the picture's own size: a poster (race and season) and a session thumbnail.
|
||||
FRAMES = {"poster": (1000, 1500), "thumb": (1920, 1080)}
|
||||
@@ -69,7 +72,7 @@ class Options:
|
||||
accent: str
|
||||
width: int
|
||||
format: str
|
||||
versioned: bool # the address carries the current render version (?v=)
|
||||
versioned: bool # the address carries the current address version (?v=)
|
||||
|
||||
def canonical(self) -> str:
|
||||
"""The options as they are drawn, the style resolved: two addresses that draw the same picture match."""
|
||||
@@ -157,7 +160,7 @@ def parse_options(items: Iterable[tuple[str, str]], kind: str) -> Options:
|
||||
|
||||
fmt = _choice("format", given.get("format", "png"), tuple(FORMATS))
|
||||
return Options(style=style, bg=bg, photo=photo, show=show, locator=locator, checker=checker, track=track,
|
||||
dim=dim, accent=accent, width=width, format=fmt, versioned=given.get("v") == RENDER_VERSION)
|
||||
dim=dim, accent=accent, width=width, format=fmt, versioned=given.get("v") == ADDRESS_VERSION)
|
||||
|
||||
|
||||
# ------------------------------------------------------------------ keys
|
||||
@@ -194,7 +197,7 @@ def finished_key(route: str, options: Options, layer_keys: Iterable[str]) -> str
|
||||
# ------------------------------------------------------------------ what clients keep
|
||||
|
||||
def cache_headers(kept: bool, versioned: bool, etag: str) -> dict[str, str]:
|
||||
"""An address with the current render version is kept for good; any other a day, asked again with its ETag;
|
||||
"""An address with the current address version is kept for good; any other a day, asked again with its ETag;
|
||||
a picture served without its layer five minutes, with no ETag."""
|
||||
if not kept:
|
||||
return {"Cache-Control": "public, max-age=300"}
|
||||
|
||||
Reference in New Issue
Block a user