Skip to content

Take the site URL from setup, not from the first request - #320

Open
mraible wants to merge 9 commits into
masterfrom
absolute-url-from-config
Open

mraible wants to merge 9 commits into
masterfrom
absolute-url-from-config

Conversation

@mraible

@mraible mraible commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor
  • When site.absoluteurl is empty, the installer's bootstrap step and the registration of the first administrator save it from that request (scheme, host, port and context path).
  • InitFilter no longer stores a request-derived absolute URL for the whole application. It makes each request's URL available on its own thread for that request only, and getAbsoluteContextURL() falls back to it while site.absoluteurl is unset, logging a warning once. A request reads site.absoluteurl once, the first time it builds a link or a cache key, so its links and the key its content is cached under agree even if an administrator sets the URL meanwhile. Planet links go through getAbsoluteContextURL() too.
  • While site.absoluteurl is unset, the page, feed, site-wide and planet caches include the request's URL in their keys, so content built for one host name is only served to requests for that host name, and caching keeps working. Content rendered outside a request isn't cached, the cache warmup job waits, and the rendering caches are cleared when the URL is first saved.
  • The first Roller UI request from a global administrator saves site.absoluteurl when it's still unset, so a site upgraded without it fills it in the first time an admin opens Roller.
  • The installer, the first administrator's registration and the first admin request only save the URL when its host looks like a public name. Loopback and private addresses, and host names without a dot such as localhost or a proxy's backend name, are left for an administrator to set under Server Admin > Configuration, which the log and error messages point to.
  • Saving the URL from setup or an admin request uses compareAndSetProperty(), so when several requests try at once only the first one's URL is kept.
  • While the URL is unset, emails don't build links from the request's host name: comment and approval notifications are sent without their links, activation and invitation emails aren't sent and the caller is told why, and the pending entry notice logs a warning instead. The planet sync task and the local feed fetcher skip their work rather than store incomplete links to local weblogs.
  • The request URL now uses the request's scheme and keeps non-default ports, so HTTPS sites get https:// links. InitFilter.initialized is volatile.

What changes for an existing site with an empty site.absoluteurl (new installs set it at setup): until an administrator opens the Roller UI at a public host name or sets the URL, pages link to each request's own host and are cached per host name, and emails and background work behave as above.

Performance, measured on a copy of a production site (77 public addresses, Tomcat behind httpd, same WAR for both arms): with site.absoluteurl set and with it empty, repeat requests had the same median (1.5 ms) and throughput at 10 clients was 2,779 and 2,909 requests/second, with the same CPU. An earlier version that didn't cache while the setting was empty was about 5x slower (8.5 ms median, 566 requests/second). The same test confirmed that two host names get their own cached copies and that the first admin page view saves the https URL.

Tests: InitFilterTest (rewritten to go through doFilter, with per-host caching cases), RegisterSiteUrlTest, SiteUrlForAdminTest (including local and private hosts), SiteUrlWhileUnsetTest, MailUtilSiteUrlTest, PlanetSiteUrlTest, new InstallTest and PropertiesTest cases, and PlanetManagerLocalTest now sets the URL as a configured site would. mvn test passes, and the Playwright database-login suite passes.

The CHANGES entry is in #324.

When site.absoluteurl is empty, the installer's bootstrap step and the registration of the first administrator now save it from that request (scheme, host, port and context path). InitFilter no longer stores a request-derived absolute URL for the whole application. Instead it makes each request's URL available on its own thread for the length of that request, and getAbsoluteContextURL() falls back to it only while site.absoluteurl is unset, logging a warning once.

Page, feed, site-wide and planet output that used the request's URL is not added to the rendering caches. The request URL now uses the request's scheme and keeps non-default ports, so HTTPS sites get https:// links.
@mraible
mraible marked this pull request as ready for review November 18, 2026 00:52
… admin's request

While site.absoluteurl is unset, the page, feed, site-wide and planet caches now include the request's absolute URL in their keys instead of skipping the cache, so content built with one host name is only served to requests for that host name and caching keeps working. The first Roller UI request from a global administrator saves site.absoluteurl when it's still unset, which fills it in on sites upgraded without it.

@snoopdave snoopdave left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of 004413fce: The request-scoped URL and per-host cache keys address the main behavior. The twin has the same fix; its extra request wiring and bootstrap check reflect differences in the older branch. Two edge cases remain.

… only once

A request now reads site.absoluteurl once, the first time it builds a link or a cache key, so its links and the key its content is cached under always agree even if an administrator sets the URL meanwhile. Content rendered outside a request isn't cached while the URL is unset, the cache warmup job skips its work until then, and the rendering caches are cleared when the URL is first saved.

Saving the URL from setup or an administrator's request now uses compareAndSetProperty(), so when several requests try at once only the first one's URL is kept. Planet links also go through getAbsoluteContextURL() instead of reading the property directly.
While site.absoluteurl is unset, comment and approval notifications are still sent but leave out their links, since the only URL available is the host name of the request that caused them. Activation, invitation and pending entry emails exist to deliver a link, so they aren't sent: activation and invitation report why to the caller, and the pending entry notice logs a warning.
The planet sync task and the local feed fetcher store absolute links to each weblog. Until site.absoluteurl is set they can't build those links, so they skip their work instead of storing incomplete URLs.
The installer, the first administrator's registration and the first administrator request only save their URL as site.absoluteurl when its host looks like a public name. Loopback and private addresses, and host names without a dot such as localhost or a proxy's backend name, are left for an administrator to set under Server Administration > Configuration.
The log and error messages about an unset site URL now point to Server Admin > Configuration, matching the tab labels.
The planet sync task and local feed fetcher now wait for site.absoluteurl, so the test sets it, as a configured site would, and clears it afterwards.
@mraible

mraible commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

A second review raised a few more points, now addressed in the latest commits:

  • Emails no longer use the request's host: while site.absoluteurl is unset, comment and approval notifications are sent without their links, and activation, invitation and pending-entry emails, which exist to deliver a link, aren't sent (activation and invitation report why, the pending-entry notice logs a warning). Dropping the links keeps comment moderation mail flowing; MailUtilSiteUrlTest covers all five with a request on another host.
  • The planet sync task and the local weblog feed fetcher now skip their work until site.absoluteurl is set, instead of storing subscriptions and entries with incomplete links; PlanetSiteUrlTest covers both.
  • The installer, first-admin registration and admin-request paths no longer save a URL whose host is loopback, private, link-local, .localhost/.local or a single label such as localhost or a proxy backend name; those are left for an administrator to set. SiteUrlForAdminTest covers the rejected and accepted hosts.
  • I left the cache bound as is: the rendering caches are fixed-size LRUs (400 page, 200 feed, 50 site-wide, 10 planet entries), and their keys already include request-chosen values such as tags, dates and page numbers, so varying the Host adds no new way to evict entries or use memory. Per-host keys also only apply until the URL is set, and the cached entries are cleared when it is.

@mraible
mraible requested a review from snoopdave November 18, 2026 04:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants