Mostlylucid.BotDetection.StyloExtract 8.8.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package Mostlylucid.BotDetection.StyloExtract --version 8.8.2
                    
NuGet\Install-Package Mostlylucid.BotDetection.StyloExtract -Version 8.8.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Mostlylucid.BotDetection.StyloExtract" Version="8.8.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Mostlylucid.BotDetection.StyloExtract" Version="8.8.2" />
                    
Directory.Packages.props
<PackageReference Include="Mostlylucid.BotDetection.StyloExtract" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Mostlylucid.BotDetection.StyloExtract --version 8.8.2
                    
#r "nuget: Mostlylucid.BotDetection.StyloExtract, 8.8.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Mostlylucid.BotDetection.StyloExtract@8.8.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Mostlylucid.BotDetection.StyloExtract&version=8.8.2
                    
Install as a Cake Addin
#tool nuget:?package=Mostlylucid.BotDetection.StyloExtract&version=8.8.2
                    
Install as a Cake Tool

Mostlylucid.BotDetection.StyloExtract

Bridge pack between StyloExtract and StyloBot's IActionPolicy registry. Provides four named action policies that operators reference by name from EndpointPolicy rules.

This package replaces Mostlylucid.StyloExtract.StyloBot (1.6.x). The source has moved into the stylobot repo so it co-evolves with Mostlylucid.BotDetection via ProjectReference.

Setup

builder.Services.AddStyloExtract(o => o.StorePath = "styloextract.db");
builder.Services.AddBotDetection(); // or AddStyloBot()
builder.Services.AddStyloExtractActionPolicies();

AddStyloExtractActionPolicies() is in the Mostlylucid.BotDetection.StyloExtract.Extensions namespace.

Policies

Name Behaviour
content-cache-search Bounded, process-local HTML cache for search engines. A hit short-circuits before the endpoint; a miss captures a cacheable HTML response and stores it.
extract-markdown-cache-ai Bounded, process-local HTML→Markdown cache for verified AI-scraper traffic only (BotType=AiBot). A hit serves cached Markdown; a miss extracts from the captured HTML, stores and serves it. Never serves Markdown to browsers.
extract-headers Adds X-StyloExtract-* response headers. Body unchanged.
extract-sidecar Adds Link: <url>; rel="alternate"; type="text/markdown" header. Body unchanged.
extract-passthrough Explicit no-op. Returns Allowed immediately without invoking the extractor.

All policies return ActionResult.Allowed - they transform the response but never block the request. Any extraction failure is logged at Warning and the original response is preserved (fail-open, always). The two content-cache policies use a per-policy bounded LFU store (TransformedContentCache bounds, sliding idle + absolute expiry, entry-byte and total-byte caps) and are never persistent or distributed.

Configuration

Options are read from StyloExtract:Actions:{policyName} in appsettings.json:

{
  "StyloExtract": {
    "Actions": {
      "extract-markdown-cache-ai": {
        "Profile": "RagFull",
        "EnableQueryOverride": true,
        "QueryParamName": "markdown",
        "QueryParamValue": "true",
        "TransformedContentCache": {
          "Enabled": true,
          "MaxEntries": 128,
          "MaxEntryBytes": 262144,
          "MaxTotalBytes": 33554432,
          "SlidingExpiration": "00:30:00",
          "AbsoluteExpiration": "24:00:00",
          "VersionSalt": "v2",
          "AllowedQueryKeys": ["page", "q"]
        },
        "Cache": {
          "Mode": "Override",
          "MaxAge": 3600,
          "Public": true,
          "VaryByBotType": true,
          "VaryByAccept": false
        }
      },
      "extract-sidecar": {
        "SidecarRouteTemplate": "/{path}.md"
      }
    }
  }
}

StyloExtractActionOptions

Field Type Default Description
Profile ExtractionProfile RagFull Controls which content appears in the Markdown output.
EnableQueryOverride bool true When true, ?markdown=true (the explicit test action) triggers the Markdown body swap regardless of bot-type. Separately labelled in telemetry; uses the Markdown variant's cache keys only.
QueryParamName string "markdown" Query parameter name for the override.
QueryParamValue string "true" Query parameter value for the override.
TransformedContentCache.Enabled bool false Whether this policy's bounded store is active.
TransformedContentCache.MaxEntries int 128 Entry cap for this policy's LFU store (per-policy).
TransformedContentCache.MaxEntryBytes int 262144 Body+headers buffered per entry; larger responses pass through unstored.
TransformedContentCache.MaxTotalBytes int 33554432 Hard payload bound; startup validates MaxEntries * MaxEntryBytes <= MaxTotalBytes.
TransformedContentCache.SlidingExpiration TimeSpan 00:02:00 Idle expiry for this policy's store.
TransformedContentCache.AbsoluteExpiration TimeSpan 00:15:00 Non-extendable absolute expiry for this policy's store.
TransformedContentCache.VersionSalt string "v1" Transform/version salt in the cache key; bumping invalidates all entries.
TransformedContentCache.AllowedQueryKeys string[] [] Query keys participating in the cache key. Empty = all keys (back-compat default).
Cache.Mode Respect\|Override\|Add Respect How Cache-Control is modified.
Cache.MaxAge int? null Maps to max-age=N seconds.
Cache.Public bool? null Adds public directive.
Cache.NoStore bool? null Adds no-store.
Cache.MustRevalidate bool? null Adds must-revalidate.
Cache.VaryByBotType bool false Appends X-StyloBot-BotType to Vary.
Cache.VaryByAccept bool false Appends Accept to Vary.
SidecarRouteTemplate string "/{path}.md" Template for the sidecar Link header. {path} = full path, {slug} = last segment.

Wiring in EndpointPolicy rules

{
  "BotDetection": {
    "Policies": {
      "api-bots": {
        "Endpoints": ["/docs/*"],
        "Types": ["AiBot"],
        "ActionPolicyName": "extract-markdown-cache-ai"
      }
    }
  }
}
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
8.10.0 96 8/16/2026
8.9.4 89 8/16/2026
8.9.3 91 8/14/2026
8.9.1 94 8/12/2026
8.9.0 91 8/12/2026
8.8.2 76 8/12/2026
8.8.1 95 8/10/2026
8.7.0 99 8/4/2026
8.6.0 101 8/1/2026
8.5.4 101 7/27/2026
8.5.1 109 7/26/2026
8.5.0 103 7/26/2026
1.0.0 107 7/25/2026