Map: with no tile server, the world's outline is inlined into every map page instead of being a cached static file #1153

Closed
opened 2026-10-31 03:04:23 +00:00 by tiagoagueda · 0 comments
Owner

What exists today

jobs/outline.py:23-47 parses templates/jobs/map/world_outline.html (39,066 bytes, one SVG path) into 278 rings, cached per process with lru_cache. jobs/views.py:781 (the place picker of one company) and jobs/views.py:924 (the companies' map) put outline.rings() in the context when tiles.current().fetched is false, and templates/jobs/company_map.html:33 writes it into data-map-outline with as_json (core/templatetags/postulo.py:800-807). static/js/app.js:9060 and 9203 read it back. The template file is no longer included anywhere else; it is only a data source.

Measured with the venv: the JSON is 44,682 bytes (only digits and brackets, so autoescaping adds nothing) and 14,220 bytes gzip. The ledger's 52 kB was high. Signed-in pages are no-store (#787), so the attribute is sent on every view; the same data as a static file would be fetched once per release.

The scout did not note that this applies only to POSTULO_MAP_TILES=none (jobs/tiles.py:137-141); OpenStreetMap is the default since 2026-10-12, so most instances never send the outline. That is why the win is small.

What would change

  • Generate static/maps/world-outline.json from world_outline.html (the rings exactly as outline.rings() returns them) with a small script, commit it, and have CI check it is current, like the other committed assets; or drop the SVG file and keep only the JSON as the one copy of the drawing.
  • The pages carry data-map-outline-src="{% static 'maps/world-outline.json' %}" instead of the data, and app.js fetches it (same origin, allowed by connect-src 'self') before drawing the outline. WhiteNoise serves it hashed, gzip and Brotli compressed, and cached for good.
  • outline.py and its lru_cache go, unless something server-side still needs the rings.

What it saves or protects

small: 44.7 kB of HTML (14.2 kB gzip) per view of the companies' map and of a company's place picker, only on instances whose tiles are set to None; the default, OpenStreetMap, sends none of it

Accessibility

none: the outline is decoration under Leaflet's markers; the map's table alternative (data-map-table, company_map.html:135) is unaffected

Decisions

  • Keep the SVG as the source and generate the JSON, or keep only the JSON? Recommended: keep only the JSON; nothing else includes the SVG any more, and one copy cannot drift.

Found by the efficiency and reliability audit of 2026-10-30 (finding A7; index postulo/postulo#1108). Checked against main at daee30b15 (2026-10-30).

## What exists today `jobs/outline.py:23-47` parses `templates/jobs/map/world_outline.html` (39,066 bytes, one SVG path) into 278 rings, cached per process with `lru_cache`. `jobs/views.py:781` (the place picker of one company) and `jobs/views.py:924` (the companies' map) put `outline.rings()` in the context when `tiles.current().fetched` is false, and `templates/jobs/company_map.html:33` writes it into `data-map-outline` with `as_json` (`core/templatetags/postulo.py:800-807`). `static/js/app.js:9060` and `9203` read it back. The template file is no longer included anywhere else; it is only a data source. Measured with the venv: the JSON is 44,682 bytes (only digits and brackets, so autoescaping adds nothing) and 14,220 bytes gzip. The ledger's 52 kB was high. Signed-in pages are `no-store` (#787), so the attribute is sent on every view; the same data as a static file would be fetched once per release. The scout did not note that this applies only to `POSTULO_MAP_TILES=none` (`jobs/tiles.py:137-141`); OpenStreetMap is the default since 2026-10-12, so most instances never send the outline. That is why the win is small. ## What would change - Generate `static/maps/world-outline.json` from `world_outline.html` (the rings exactly as `outline.rings()` returns them) with a small script, commit it, and have CI check it is current, like the other committed assets; or drop the SVG file and keep only the JSON as the one copy of the drawing. - The pages carry `data-map-outline-src="{% static 'maps/world-outline.json' %}"` instead of the data, and `app.js` fetches it (same origin, allowed by `connect-src 'self'`) before drawing the outline. WhiteNoise serves it hashed, gzip and Brotli compressed, and cached for good. - `outline.py` and its `lru_cache` go, unless something server-side still needs the rings. ## What it saves or protects small: 44.7 kB of HTML (14.2 kB gzip) per view of the companies' map and of a company's place picker, only on instances whose tiles are set to None; the default, OpenStreetMap, sends none of it ## Accessibility none: the outline is decoration under Leaflet's markers; the map's table alternative (`data-map-table`, `company_map.html:135`) is unaffected ## Decisions - **Keep the SVG as the source and generate the JSON, or keep only the JSON?** Recommended: keep only the JSON; nothing else includes the SVG any more, and one copy cannot drift. --- Found by the efficiency and reliability audit of 2026-10-30 (finding A7; index postulo/postulo#1108). Checked against `main` at `daee30b15` (2026-10-30).
tiagoagueda added this to the 0.6.0 milestone 2026-10-31 03:04:23 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Postulo/postulo#1153
No description provided.