Skip to content

Include the page number in feed cache keys and limit page numbers - #313

Merged
mraible merged 5 commits into
masterfrom
feed-cache-page-key
Nov 20, 2026
Merged

mraible merged 5 commits into
masterfrom
feed-cache-page-key

Conversation

@mraible

@mraible mraible commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor
  • Feed requests for later pages of entries (?page=N) now get their own keys in the weblog feed cache and the site-wide cache, the way the page cache already does. The page number is added only after the first page, so existing keys don't change. The search term and each tag name in a feed key are now URL-encoded, as the category name already was, so a / in a term or tag can't look like the page number or another part of the key.
  • The page parameter of feed, page and search requests is kept between 0 and 10,000 when parsed (WeblogRequest.parsePageNum), so the pager offset computed from it stays in range. A missing or unparsable value means the first page. The tag data servlet answers 400 for page numbers below 0 or above 10,000, as it already did for ones that aren't numbers.
  • Pagers, the feed history links and the tag data XML don't offer a Next link on page 10,000, since the following page would be read as page 10,000 again.
  • PageServlet now skips the page cache only when the server sets the skipCache request attribute, as it does for forwarded comment posts. It no longer reads a skipCache query parameter, which nothing in Roller's templates, JSPs or docs uses, and WeblogPageRequest no longer passes that parameter on to templates as a custom parameter, so it doesn't add entries to the page cache either.

Tests: WeblogFeedCacheKeyTest (including terms and tags such as foo/page=2, foo/excerpts and a+b), PageParameterTest, PageServletCacheTest, PagerNextLinkLimitTest and TagDataServletPageTest. mvn test passes.

CHANGES entries for this and the related fixes will come in one PR, so these don't conflict with each other.

A further review pass added these fixes:

  • Next and previous links in search, entry, comment and media file feeds no longer fail with a server error when the feed URL has q, cat, tags or excerpts together with page.
  • The tag data service returns exactly services.tagdata.max tags per page, so a tag no longer appears at the end of one page and again at the start of the next.

Feed requests for later pages of entries now get their own keys in the weblog feed cache and the site-wide cache, so each page is cached separately. The page number is added only after the first page, so existing keys stay the same.

The page request parameter for feeds and weblog pages is now kept between 0 and 10000 when parsed, so the pager offset computed from it stays within range.

The page servlet now skips the page cache only when the server sets the skipCache request attribute, as it does for forwarded comment posts, and no longer reads a skipCache query parameter.

@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 2be6137de: The twin PR has the same fix hunks, apart from the expected javax/jakarta imports. The main paths have regression tests, but the cache key format and two other page parsers still need changes.

WeblogFeedCache and SiteWideCache now URL-encode the search term and each tag name in feed keys, as they already do for the category name, so a "/" in a term or tag can't make it look like the page number or another key part. WeblogFeedCacheKeyTest checks that terms and tags such as "foo/page=2", "foo/excerpts" and "a+b" get keys of their own.
…e limit

WeblogSearchRequest now reads the page parameter with the same parser as weblog pages and feeds, so it stays between 0 and 10000. TagDataServlet returns 400 for page numbers below 0 or above 10000, as it already does for page numbers that aren't numbers.

Pagers, the feed history links and the tag data XML no longer offer a Next link on page 10000, since a request for the following page would be read as page 10000 again.
WeblogPageRequest no longer passes a skipCache query parameter on to templates as a custom parameter. The page servlet no longer reads that parameter, and custom parameters are part of the page cache key, so each skipCache value would otherwise get its own cache entry. PageParameterTest checks that skipCache is dropped and other custom parameters are kept.
@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:

  • WeblogPageRequest now leaves a skipCache query parameter out of the custom parameters, which are part of the page cache key, so each skipCache value no longer gets its own entry now that the page servlet ignores that parameter. PageParameterTest checks it, and Include the page number in feed cache keys and limit page numbers #325 has the same change.

@mraible
mraible requested a review from snoopdave November 18, 2026 04:15
The next and previous links of the search, entries, comments and media file feed pagers threw UnsupportedOperationException whenever the feed request had a search term, category, tags or excerpts, because AbstractPager handed createURL an immutable map that those pagers add their parameters to. It now passes a mutable map.

TagDataServlet fetches one tag more than a page holds to find out whether there is a next page, and it printed that extra tag too, so every full page had one tag too many and that tag showed up again at the top of the next page. Both the JSON and XML output now stop at the page size.

@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 e4d3d16aa: The current diff addresses the earlier review points. The production fix hunks match #325 after accounting for branch differences; the tag data tests use different JSON assertions. No new code defect was verified.

Earlier comments: 3 of 3 resolved.

No new issues found.

@mraible
mraible merged commit 428958b into master Nov 20, 2026
9 checks passed
@mraible
mraible deleted the feed-cache-page-key branch November 20, 2026 00:51
mraible added a commit to mraible/roller that referenced this pull request Nov 20, 2026
Adds bug-fix and behaviour-change entries for apache#313 to apache#319 and apache#321 to apache#323.
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