Skip to content

Limit embeds of speculative pages that aren't in scope - #838

Open
krushna-sahu1 wants to merge 2 commits into
internetarchive:masterfrom
krushna-sahu1:speculative-html-embeds
Open

krushna-sahu1 wants to merge 2 commits into
internetarchive:masterfrom
krushna-sahu1:speculative-html-embeds

Conversation

@krushna-sahu1

Copy link
Copy Markdown
Contributor

Fixes #826.

Speculative links (e.g. URLs found in JavaScript) are transcluded even when they're out of scope. When one turns out to be an HTML page, its own embeds get transcluded too, so a single-page crawl can end up pulling in the resources of hundreds of other pages.

This adds an optional speculativePageScope rule to TransclusionDecideRule. If a URI was discovered from a 2xx HTML page that was reached by a speculative hop (ignoring redirects), it's only transcluded when speculativePageScope accepts that page. Speculatively discovered non-HTML resources (CDN images, JSON, CSS, JS etc.), their own embeds, and redirects work as before.

In the default profiles, the hop limit is now a named tooManyHops bean, and speculativePageScope is [acceptSurts, tooManyHops]. So a speculative page only brings in its embeds if it would be in scope on its own, and maxHops is still set in one place.

As described in the issue, with maxHops=0 the number of discovered URIs went from 51,677 to 2,610 for the BBC homepage, 10,851 to 1,473 for SMH and 7,228 to 2,611 for ABC, while the speculative non-HTML resources were kept.

Tests: TransclusionDecideRuleTest covers embeds of out-of-scope speculative pages, in-scope speculative pages, speculative resources, redirects and non-HTML pages, plus the existing hop limits. ProfileCrawlerBeansTest passes for both profiles.

TransclusionDecideRule accepts the embeds of a speculatively discovered
page even when the page itself is out of scope, so a URL found in
JavaScript that turns out to be an HTML page pulls in all of that page's
resources.

Add an optional speculativePageScope rule. When set, URIs discovered from
an HTML page reached by a speculative hop are only transcluded if that
rule accepts the page. Speculatively discovered non-HTML resources and
redirects are unaffected.
The default profiles transcluded the embeds of every speculatively
discovered page, including same-site pages beyond maxHops, which grew a
single-page crawl of a news homepage to tens of thousands of URIs.

Make the hop limit a named tooManyHops bean and set TransclusionDecideRule's
speculativePageScope to accept pages within the SURT prefixes and hop limit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Speculative HTML pages pull their embeds past scope and maxHops

1 participant