Server: Assets werden nachgefragt statt jedes Mal neu geladen
Auf allem stand no-store -- im Server und noch einmal in preloadAssets(). Der Browser durfte also nichts behalten, und jeder Reload lud die vollen Assets neu: 3 MB Screenshots, 3,3 MB Mockups, Schriften, Bibliotheken. Am schlimmsten in uebersicht.html. Die laedt die sechs Projekte als iframes, und weil keiner etwas behalten durfte, holte sich jeder iframe dieselben Dateien noch einmal: 38,1 MB in 435 Anfragen. uebersicht.html erster Aufruf 38,1 MB -> 2,2 MB uebersicht.html Reload 32,8 MB -> 1,9 MB post6.html Reload 5,4 MB -> 0,3 MB Die Absicht hinter no-store war richtig: ein Bild, das unter demselben Namen ausgetauscht wird, muss sofort ankommen. no-cache leistet das billiger -- der Browser behaelt seine Kopie, fragt aber vor jeder Benutzung nach. Nachgeprueft: unveraendert antwortet der Server mit 304 und 0 Bytes, nach einem touch mit 200 und der vollen Datei. Seite, Stand und Auskuenfte (/bilder, /state) bleiben bei no-store. Die sind klein und duerfen nie aus einer Kopie kommen. Die eine Zeile stand in allen sieben Projektdateien. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01U7RZ6ZpLD8Dp84Rtt4KHfv
This commit is contained in:
1 parent
e8f5686f30
commit
77734b6da2
9 files changed
+111
-20
No files matched your search
+8
-2
@@ -4025,7 +4025,13 @@ if (location.search.indexOf("nur=anim") >= 0)
|
||||
const optional = new Set(["./assets/mockups/laptop.png", "./assets/mockups/macbook-fels.png"]);
|
||||
paths.push("./assets/mockups/laptop.png", "./assets/mockups/macbook-fels.png");
|
||||
for (const path of [...new Set(paths)]) {
|
||||
const res = await fetch(path, { cache: "no-store" }).catch(() => null);
|
||||
/* no-cache statt no-store: der Browser behaelt seine Kopie und fragt
|
||||
nur nach, ob sie noch stimmt. Ein ausgetauschtes Bild kommt genauso
|
||||
sofort an, ein unveraendertes kostet ein 304 statt seiner vollen
|
||||
Groesse. Mit no-store lud jeder Reload alle Assets neu -- ueber
|
||||
uebersicht.html, die sechs Projekte als iframes laedt, waren das
|
||||
38 MB und 21 Sekunden. */
|
||||
const res = await fetch(path, { cache: "no-cache" }).catch(() => null);
|
||||
if (!res || !res.ok) {
|
||||
if (optional.has(path)) continue;
|
||||
throw new Error(path + " -> HTTP " + (res ? res.status : "kein Zugriff"));
|
||||
@@ -4603,7 +4609,7 @@ if (location.search.indexOf("nur=anim") >= 0)
|
||||
// Eine Datei einlesen, damit sie sofort im Canvas und im Export vorliegt.
|
||||
async function bildBereitstellen(pfad) {
|
||||
if (assets[pfad]) return true;
|
||||
const res = await fetch(pfad, { cache: "no-store" }).catch(() => null);
|
||||
const res = await fetch(pfad, { cache: "no-cache" }).catch(() => null);
|
||||
if (!res || !res.ok) return false;
|
||||
const blob = await res.blob();
|
||||
assets[pfad] = await new Promise((ok, fail) => {
|
||||
|
||||
Reference in new issue
Block a user